ADO recordsource syntax

Posted on 2003-03-22
Medium Priority
Last Modified: 2013-12-25
Attempting to do a SQL query to an Access DB using the ADO control
getting a type mismatch.

Private Sub cmdSearch_Click()
frmCMS.Adodc1.RecordSource = _
    "select * from tblTable where IDNum = '" & txtIDSrch.Text
End Sub
where txtIDSrch is a TextBox

If I enter 1014 in the texbox
get the error

Syntax error in query expression 'IDNum='1014'  

I'm sure that this is a simple thing on my part, but Im kind of new at this string within a string thing
Question by:jackassplus
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
1 Comment
LVL 33

Accepted Solution

hongjun earned 200 total points
ID: 8189025
Try this if IDNum is a string field
frmCMS.Adodc1.RecordSource = _
"select * from tblTable where IDNum = '" & txtIDSrch.Text & "'"

Try this if IDNum is an integer field
frmCMS.Adodc1.RecordSource = _
"select * from tblTable where IDNum = " & txtIDSrch.Text


Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

770 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