Solved

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

Posted on 2011-02-25
4
352 Views
Last Modified: 2013-11-28
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
0
Comment
Question by:deefel
  • 2
4 Comments
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 50 total points
ID: 34985207
maybe [SwitchboardID] is Text Data Type

    stSql = "SELECT * FROM [Switchboard Items]"
    stSql = stSql & " WHERE [ItemNumber] > 0 AND [SwitchboardID]='" & Me.[SwitchboardID] & "'"
    stSql = stSql & " ORDER BY [ItemNumber];"
 
0
 
LVL 84
ID: 34985533
Also make sure you've spelled everything correctly.
0
 
LVL 15

Expert Comment

by:cquinn
ID: 34988501
You don't use CreateObject ti instantiate a recordset in Access

0
 
LVL 84
ID: 34988959
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.
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now