Microsoft Office Tutorials and References
In Depth Information
Step-by-Step
12.
Examine the Database1.accdb file to confirm the existence of your new field for a middle
name. Figure 29-3 shows what you should see, and the following code shows the complete
macro.
figurE 29-3
Sub AddNewField()
‘Declare variables
Dim dbConnection As ADODB.Connection
Dim dbCommand As ADODB.Command
Dim dbFileName As String
‘Define the Access database path and name.
dbFileName = “C:\YourFilePath\Database1.accdb”
‘Set the assignment to open the connection.
Set dbConnection = New ADODB.Connection
‘Define the Provider and open the connection.
With dbConnection
.Provider = “Microsoft.ACE.OLEDB.12.0;Data Source=” & dbFileName & _
“;Persist Security Info=False;”
.Open dbFileName
End With
‘Set the Command variables.
Set dbCommand = New ADODB.Command
Set dbCommand.ActiveConnection = dbConnection
Search JabSto ::




Custom Search