G
Guest
Hi all,
I am new in VBA Programming on my Access 2003 of Office 2003 that is built
on Windows XP Pro-Microsoft NT 4. I got a Run-Time error
'2147217900(80040e14):
Invalid SQL statement: expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT',
or 'UPDATE', when I executed the attached progrm. The Debug points on the
statement 'rest1.Open "AllEmployees", cnn1'. This error message does not
make sense to me. Please help and advise me what is wrong with the program
and how to solve the problem.
Thankls in advance,
SHC
/////////////////////////////////////
Sub ViewAView()
Dim cnn1 As New ADODB.Connection
Dim rst1 As New ADODB.Recordset
Dim intMaxLength As Integer, Length As Integer, strFiller As Integer
' Open the connection.
cnn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Program Files\Microsoft
Office\Office11\Samples\Northwind.mdb;"
'Find the longest name.
rst1.Open "AllEmployees", cnn1
Do Until rst1.EOF
Length = Len(rst1.Fields("FirstName")) + _
Len(rst1.Fields("LastName"))
If Length > intMaxLength Then intMaxLength = _
Length
rst1.MoveNext
Loop
'Print first name, last name, and third field.
rst1.MoveFirst
Do Until rst1.EOF
strFiller = (intMaxLength + 2) - _
(Len(rst1.Fields("FirstName")) + _
Len(rst1.Fields("LastName")))
Debug.Print rst1.Fields("FirstName") & " " & _
rst1.Fields("LastName") & String(strFiller, " ") & _
rst1.Fields(2)
rst1.MoveNext
Loop
End Sub
I am new in VBA Programming on my Access 2003 of Office 2003 that is built
on Windows XP Pro-Microsoft NT 4. I got a Run-Time error
'2147217900(80040e14):
Invalid SQL statement: expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT',
or 'UPDATE', when I executed the attached progrm. The Debug points on the
statement 'rest1.Open "AllEmployees", cnn1'. This error message does not
make sense to me. Please help and advise me what is wrong with the program
and how to solve the problem.
Thankls in advance,
SHC
/////////////////////////////////////
Sub ViewAView()
Dim cnn1 As New ADODB.Connection
Dim rst1 As New ADODB.Recordset
Dim intMaxLength As Integer, Length As Integer, strFiller As Integer
' Open the connection.
cnn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Program Files\Microsoft
Office\Office11\Samples\Northwind.mdb;"
'Find the longest name.
rst1.Open "AllEmployees", cnn1
Do Until rst1.EOF
Length = Len(rst1.Fields("FirstName")) + _
Len(rst1.Fields("LastName"))
If Length > intMaxLength Then intMaxLength = _
Length
rst1.MoveNext
Loop
'Print first name, last name, and third field.
rst1.MoveFirst
Do Until rst1.EOF
strFiller = (intMaxLength + 2) - _
(Len(rst1.Fields("FirstName")) + _
Len(rst1.Fields("LastName")))
Debug.Print rst1.Fields("FirstName") & " " & _
rst1.Fields("LastName") & String(strFiller, " ") & _
rst1.Fields(2)
rst1.MoveNext
Loop
End Sub