Solved

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

Posted on 2011-02-25
4
356 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) 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 85
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 85
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

688 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