473,395 Members | 1,583 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

what sql string has to be?

Hi all,
I try to query the record MemberID = <some number as long type>. I don't
know what symbol I have to patch to the sql string to open the DAO
recordset, can someone shed some light on this please.

Here's my sample code

when I use the single quote <'>, it give me error: 3464 datatype mismatch in
criteria expression
sql = "SELECT * FROM TblMembers WHERE MemberID = " & "'" & s & "'"
Set rs = db.OpenRecordset(sql, dbOpenDynaset)

when I use the number sign <#>, it give me error: 3075 Syntax error in date
in query expression 'MemberID = #232#'
sql = "SELECT * FROM TblMembers WHERE MemberID = " & "#" & s & "#"
Set rs = db.OpenRecordset(sql, dbOpenDynaset)

The data type defined for MemberID is LONG

Thanks for your help
Jing.
Nov 13 '05 #1
2 1447
The ' is used to simplify putting quotes (") around strings instead of using
double up quotes to generate this. It make it easier to read, but is still a
string delimiter. The # is a date delimiter. Numbers need no delimiter.
Since you say that MemberID is a Long Interger then I assume the s is a
variable holding a long integer.

sql = "SELECT * FROM TblMembers WHERE MemberID = " & s

--
Wayne Morgan
MS Access MVP
"JingleBEV" <n_****@NOSPAMyahoo.com> wrote in message
news:4m*********************@news20.bellglobal.com ...
Hi all,
I try to query the record MemberID = <some number as long type>. I don't
know what symbol I have to patch to the sql string to open the DAO
recordset, can someone shed some light on this please.

Here's my sample code

when I use the single quote <'>, it give me error: 3464 datatype mismatch in criteria expression
sql = "SELECT * FROM TblMembers WHERE MemberID = " & "'" & s & "'"
Set rs = db.OpenRecordset(sql, dbOpenDynaset)

when I use the number sign <#>, it give me error: 3075 Syntax error in date in query expression 'MemberID = #232#'
sql = "SELECT * FROM TblMembers WHERE MemberID = " & "#" & s & "#"
Set rs = db.OpenRecordset(sql, dbOpenDynaset)

The data type defined for MemberID is LONG

Thanks for your help
Jing.

Nov 13 '05 #2
"JingleBEV" <n_****@NOSPAMyahoo.com> wrote in message
news:4m*********************@news20.bellglobal.com ...
Hi all,
I try to query the record MemberID = <some number as long type>. I don't
know what symbol I have to patch to the sql string to open the DAO
recordset, can someone shed some light on this please.


Strings and dates need to be delimited. Numbers do not need a delimiter at
all so just leave them off and your SQL should work.
sql = "SELECT * FROM TblMembers WHERE MemberID = " & s
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

56
by: Xah Lee | last post by:
What are OOP's Jargons and Complexities Xah Lee, 20050128 The Rise of Classes, Methods, Objects In computer languages, often a function definition looks like this: subroutine f (x1, x2, ...)...
5
by: Ali Eghtebas | last post by:
Hi, I've made this regex to catch the start of a valid multiline comment such as "/*" in e.g. T-SQL code. "(?<=^(?:*'*')*?*)(?<!^(?:*'*')*?--.*)/\*.*?$" With Multiline option on. As we know...
13
by: William Ryan | last post by:
I just picked up a copy of John Robbins' debugging book and started to look at disassembled code. Anyway, I hate optional Parameters in VB, but I was checking them out to see what IL is created. ...
24
by: Massimo Soricetti | last post by:
Think for a moment: IF you were Bjarne Stroustrup in 1985 (or whenever he were doing it) writing down C++, and knowing all you know NOW of the C++ language, (pro, cons, features of today...
8
by: werner | last post by:
Hi! I don't want to use eval() in order to parse a user-supplied formula. What alternatives do I have? PHP has no standard functionality for tokenizing or parsing expressions in this regard. ...
14
by: Rich | last post by:
Yes, I need to store some values in an array type collection object that can hold 3 or more parameters per index. I have looked at the collection object, hashtable object and would prefer not to...
98
by: tjb | last post by:
I often see code like this: /// <summary> /// Removes a node. /// </summary> /// <param name="node">The node to remove.</param> public void RemoveNode(Node node) { <...> }
6
by: JonathanOrlev | last post by:
Hello everyone, I have a newbe question: In Access (2003) VBA, what is the difference between a Module and a Class Module in the VBA development environment? If I remember correctly, new...
1
by: td0g03 | last post by:
Hello, I am new to C and I am new to English. I not sure what palindromes mean. I don't know exactly what my teacher wants me to do. If someone could explain it to me in a different way that would be...
10
by: DavidSeck.com | last post by:
Hi, I am working with the Facebook API right now, an I have kind of a problem, but I don't know what I am doing wrong. So I have a few arrays, f.ex.: User albums: array(2) {
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.