Hello All!
I am using Access 2007, VBA, Using ADO and following along from the manuals which seem to be on target. Have moved to using ADO in the
VB Scripting. All seemed well until I decided to try and implement adding additional columns to an existing table. The manual (Dummies) advised to set up the connection which I believe I did as I alias'd con1 As ADODB.Connection and followed the remaining steps as laid out in the manual. Obviously I am new to
VB and could use a pointer.
Case is as follows:
I have a test db named Handlers2
I have two tables that I created using
VB. (Picture Happy Dance Here!!!)
I want to add some fields to tblEmployees. (Currently only has ID field)
I am running into syntax errors. Mostly it seems to bomb on the DoCmd****nSQL mySQL
I KNOW I have a syntax error going on. Can you review the statement for me please and give me a suggestion as to what I am doing wrong when you have a minute. (I know the simple answer is to go into design view on the table and add the fields)
Code:
Option Compare Database
Sub UptdateEmployeetbl()
Dim con1 As ADODB.Connection
Set con1 = CurrentProject.Connection
Dim myRecordSet As New ADODB.Recordset
myRecordSet.ActiveConnection = con1
myRecordSet.CursorType = adOpenDynamic
myRecordSet.LockType = adLockOptimistic
Dim mySQL As String
mySQL = mySQL & " (UPDATE tblEmployees "
mySQL = mySQL & " [FirstName] text (20),"
mySQL = mySQL & " [LastName] text (25),"
mySQL = mySQL & " [StreetAddress] text (50),"
mySQL = mySQL & " [LocationCity] text (25),"
mySQL = mySQL & " [State] text (15),"
mySQL = mySQL & " [County] text (25)"
mySQL = mySQL & " [Country] text (15),"
mySQL = mySQL & " [PostalCode] text (20))"
DoCmd****nSQL mySQL
End Sub
What happens is that the code fails and the DoCmd is highlighted in Yellow.
Can someone give me a pointer as to where I have gone wrong?
Thanks in advance!