Link to home
Start Free TrialLog in
Avatar of DeeDee Baldwin
DeeDee BaldwinFlag for United States of America

asked on

How do I get fix code to not get Run time Error 2147217900

I am trying to troubleshoot a database that after the user enter the necessary dates and hit enter gets a run time error 2147217900(80040e14) Synatx error (missing operator) in query expression [ItemNumber] > 0 and [SwitchboardID]=" & Me.[SwitchboardID]

Below is the Code
' Open the table of Switchboard Items, and find
    ' the first item for this Switchboard Page.
    Set con = Application.CurrentProject.Connection
    stSql = "SELECT * FROM [Switchboard Items]"
    stSql = stSql & " WHERE [ItemNumber] > 0 AND [SwitchboardID]=" & Me.[SwitchboardID]
    stSql = stSql & " ORDER BY [ItemNumber];"
    Set rs = CreateObject("ADODB.Recordset")
    rs.Open stSql, con, 1   ' 1 = adOpenKeyset
Could someone please help.  Thanks
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also make sure you've spelled everything correctly.
You don't use CreateObject ti instantiate a recordset in Access

You don't TYPICALLY use CreateObject to build a Recordst, but there's nothing wrong with using CreateObject to build a Recordset (other than you don't get Intellisense).

In fact there is a new issue out that could force you to use Late Binding to build ADO recordsets:

http://social.msdn.microsoft.com/Forums/en-US/windowsgeneraldevelopmentissues/thread/3a4ce946-effa-4f77-98a6-34f11c6b5a13/?prof=required

Seems that Servic Pack 1 for Win7 can break the mosadoxx.dll associations (the ID for that interface changed), which means you must either (a) register an earlier version of that TypeLib or (b) user Late Binding.