Wow! So much info at once. Ok here is what I need to do. I need to add a table to my existing MS Access database called TempDocAudio with a text field called "n_id" and add two fields to an existing table called Documents and the new text fields are "n_mp3" and "n_wavBol" all of the same database.
So maybe you guys can help me script this out. In my module I set up a sub like this to access my database then when ever I need to make a call to the db I do a Call CreateConnection(objConn) and then Call CloseConnection(objConn).
VB Code:
Sub CreateConnection(objConn As Connection) ' CONNECTION STRING FOR THE DATABASE AccessConnect = "DRIVER={Microsoft Access Driver (*.mdb)};" & _ "DBQ=Westfield.MDB;" & _ "DefaultDir=" & App.Path & ";" 'MsgBox AccessConnect ' Create Connection Object and open it Set objConn = New ADODB.Connection objConn.CursorLocation = adUseClient ' Trap any error/exception On Error GoTo AdoError objConn.ConnectionString = AccessConnect objConn.Open Exit Sub ' ADO Error/Exception Handler AdoError: ErrNumber = Err.Number ErrSource = Err.Source ErrDescription = Err.Description 'AdoErrorEx List1, objConn End Sub Sub CloseConnection(objConn As Connection) objConn.Close Set objConn = Nothing End Sub
So on my Sub Form Load I have this, how do I correctly scritp out what I want to do.
VB Code:
Private Sub Form_Load() On Error GoTo FormLoadError frmIntro.Caption = "1:1 card " & Chr(147) & "Because every customer is different" & Chr(153) & Chr(46) & Chr(148) frmIntro.Label1.Caption = "© Copyright 2005 Westfield Insurance. All rights reserved." 'create directories if they do not already exist If Dir(App.Path & "\" & "CDTypes", vbDirectory) = "" Then 'MsgBox "Directory doesn't exist" MkDir (App.Path & "\" & "CDTypes") ' make new directory MkDir (App.Path & "\" & "WavFiles") 'make wavFile directory Else 'MsgBox "Directory Exist" End If 'create new table TestTable Call CreateConnection(objConn) objConn.Execute "CREATE TABLE TestTable(my_id TEXT(50) NOT NULL)" Call CloseConnection(objConn) Call CreateConnection(objConn) objConn.Execute "ALTER TABLE TestTable (my_name TEXT(50) NOT NULL)" Call CloseConnection(objConn) ' Error handler FormLoadError: If Err.Number <> 0 Then errLogger Err.Number, Err.Description, "Open File" Err.Clear Resume Next 'Exit Sub End If End Sub




Reply With Quote