Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Importing / Linking / August 2005

Tip: Looking for answers? Try searching our database.

Invalid SQL Statement - View Northwind.mdb

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SHC - 17 Aug 2005 13:41 GMT
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
George Nicholson - 17 Aug 2005 18:40 GMT
I don't see a table or query named "AllEmployees" in my copy of Northwind
for 2003 (or 2002).

Is this something you added yourself, or the cause of the error?

Signature

George Nicholson

Remove 'Junk' from return address.

> Hi all,
>
[quoted text clipped - 43 lines]
>
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.