Click here to Skip to main content
16,004,854 members
Home / Discussions / Database
   

Database

 
QuestionSQL Statment Pin
webhay28-Sep-07 19:26
webhay28-Sep-07 19:26 
AnswerRe: SQL Statment Pin
John-ph28-Sep-07 20:43
John-ph28-Sep-07 20:43 
QuestionObject Persistence Pin
gus_br28-Sep-07 9:18
gus_br28-Sep-07 9:18 
AnswerRe: Object Persistence Pin
Colin Angus Mackay28-Sep-07 9:44
Colin Angus Mackay28-Sep-07 9:44 
GeneralRe: Object Persistence Pin
gus_br28-Sep-07 9:52
gus_br28-Sep-07 9:52 
GeneralRe: Object Persistence Pin
Colin Angus Mackay28-Sep-07 10:03
Colin Angus Mackay28-Sep-07 10:03 
QuestionCommon Dialog Object Reference... Pin
new_phoenix28-Sep-07 9:07
new_phoenix28-Sep-07 9:07 
QuestionHaving trouble with a TableDef object... Pin
new_phoenix28-Sep-07 6:56
new_phoenix28-Sep-07 6:56 
I would like to be able to add a field to an existing table in Microsoft Access. It is my understanding that I would need to use a TableDef object. Could you give me some insights? The code I have now is like so:

Option Compare Database

Public dbsHeadcount As Database
Public Cnxn As ADODB.Connection
Public rstHyperionMany As ADODB.Recordset

Function ProcessHeadcountFile()
    On Error GoTo ErrorHandler

    Dim strConn As String
    Dim rstLoadFile As ADODB.Recordset
    Dim cmdSQLLoadFile As ADODB.Command
    Dim strSQLLoadFile As String
    Dim rstHyperionOne As ADODB.Recordset
    Dim cmdSQLHyperionOne As ADODB.Command
    Dim strSQLHyperionOne As String
    Dim cmdSQLHyperionMany As ADODB.Command
    Dim strSQLHyperionMany As String
    Dim strFileName As String
    Dim qdfTemp As QueryDef
    Dim qdfNew As QueryDef
    Dim strHoldRecString As String
    Dim strMessage As String
    
    Set dbsHeadcount = OpenDatabase("J:\<FILEPATH>\Headcount Database.mdb")
    Set Cnxn = New ADODB.Connection
    strConn = "Provider=Microsoft.Jet.OLEDB.4.0; " & _
        "Data Source=J:\<FILEPATH>\Headcount Database.mdb;"
    Cnxn.Open strConn
    
    Call LoadExcelIntoAccessTable
    Set cmdSQLInputFile = New ADODB.Command
    Set cmdSQLInputFile.ActiveConnection = Cnxn
    Set cmdSQLHyperionMany = New ADODB.Command
    Set cmdSQLHyperionMany.ActiveConnection = Cnxn
    strSQLHyperionMany = "SELECT [COUNTRY], [TYPE], [BUSINESS UNIT], " & _
        "[L/R/G], [REGION], [JOB FUNCTION], [09/12/2007 Reported] " & _
        "FROM [tblInputFile]"
    cmdSQLHyperionMany.CommandType = adCmdText
    cmdSQLHyperionMany.CommandText = strSQLHyperionMany
    Set rstHyperionMany = cmdSQLHyperionMany.Execute()
    rstHyperionMany.MoveFirst
    Call CreateIndexesForLoadedTable
ErrorHandler:
    If Err <> 0 Then
        MsgBox Err.Source & ":" & Err.Description, , "Error and Error #" & Err.Number
    End If   
End Function

Sub LoadExcelIntoAccessTable()
    DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
        "tblInputFile", "C:/Employees.xls", True
End Sub

Sub CreateIndexesForLoadedTable()
    Dim tdfInputFile As TableDef
    Set tdfInputFile = dbsHeadcount.CreateTableDef("tblInputFile")
    tdfInputFile.Fields.Append tdfInputFile.CreateField("Date", dbDate)
    dbsHeadcount.TableDefs.Append tdfInputFile

    ERROR: Here is where it is saying that tblInputFile already exists. How do I append the field called "Date" to the existing table called tblInputFile??????????? :confused::confused::confused:

End Sub

Questioncolumn as stored procedure parameter? Pin
Ed Hill _5_28-Sep-07 6:06
Ed Hill _5_28-Sep-07 6:06 
AnswerRe: column as stored procedure parameter? Pin
John-ph28-Sep-07 10:47
John-ph28-Sep-07 10:47 
GeneralRe: column as stored procedure parameter? Pin
Ed Hill _5_1-Oct-07 0:26
Ed Hill _5_1-Oct-07 0:26 
GeneralRe: column as stored procedure parameter? Pin
John-ph2-Oct-07 19:47
John-ph2-Oct-07 19:47 
QuestionPASSWORD RETRIEVAL Pin
LyndonJohn28-Sep-07 3:34
LyndonJohn28-Sep-07 3:34 
AnswerRe: PASSWORD RETRIEVAL Pin
Pete O'Hanlon28-Sep-07 4:01
mvePete O'Hanlon28-Sep-07 4:01 
AnswerRe: PASSWORD RETRIEVAL Pin
Colin Angus Mackay28-Sep-07 4:24
Colin Angus Mackay28-Sep-07 4:24 
AnswerRe: PASSWORD RETRIEVAL Pin
Paul Conrad2-Oct-07 10:30
professionalPaul Conrad2-Oct-07 10:30 
QuestionSQL to get DataTypes Pin
RichardBerry28-Sep-07 3:21
RichardBerry28-Sep-07 3:21 
AnswerRe: SQL to get DataTypes Pin
Colin Angus Mackay28-Sep-07 3:31
Colin Angus Mackay28-Sep-07 3:31 
GeneralRe: SQL to get DataTypes Pin
RichardBerry30-Sep-07 21:16
RichardBerry30-Sep-07 21:16 
GeneralRe: SQL to get DataTypes Pin
Colin Angus Mackay1-Oct-07 6:32
Colin Angus Mackay1-Oct-07 6:32 
GeneralRe: SQL to get DataTypes Pin
RichardBerry2-Oct-07 1:20
RichardBerry2-Oct-07 1:20 
AnswerRe: SQL to get DataTypes Pin
PIEBALDconsult28-Sep-07 5:42
mvePIEBALDconsult28-Sep-07 5:42 
AnswerRe: SQL to get DataTypes Pin
John-ph28-Sep-07 20:22
John-ph28-Sep-07 20:22 
GeneralRe: SQL to get DataTypes Pin
RichardBerry30-Sep-07 21:36
RichardBerry30-Sep-07 21:36 
GeneralRe: SQL to get DataTypes Pin
John-ph30-Sep-07 22:51
John-ph30-Sep-07 22:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.