Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Database Variable Problems

Status
Not open for further replies.

vatik

Technical User
Jul 13, 2001
20
0
0
US
Im trying to access a particular field of the db with the statement

sql = "SELECT * FROM [REPAIR] WHERE [RMA#] = variable"

and it won't let me get away with it

sql = "SELECT * FROM [REPAIR] WHERE [RMA#] = 4551 "

that works just fine, but i need to put a variable in it.

any help is appreciated
 
If you are using vbscripts, try this

sql = "SELECT * FROM [REPAIR] WHERE [RMA#] = " & variable

If javascripts, try this

sql = "SELECT * FROM [REPAIR] WHERE [RMA#] = " + variable

Good luck!
 
Using VBScripts (not by choice but oh well)


Dim num
num = CInt(Request3465)

If IsObject(Session("RECEIVED_REPAIRS_rs")) Then
set rs = Session("RECEIVED_REPAIRS_rs")
Else
sql = "SELECT * FROM [REPAIR] WHERE [RMA#]=" &num
...

[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.

heh, i don't see a problem with crossed datatypes
 
There should be a space between the & and num. If that was just a typo then ignore this post. Also if RMA# is really a VARCHAR then you may need to do:
Code:
sql = "SELECT * FROM [REPAIR] WHERE [RMA#]='" & num & "'"
Wushutwist
 
what kind of datatype is [RMA#] ? if it's a date, surround it by hash marks. if it's a char data type, surround it by ' marks. if it's a number, you need not do anything.

and - I don't know if this is a typo

but
num = CInt(Request3465) should be
num = CInt(Request("3465")) 'or whatever the form name is

hope this helps
leo
 
What is the data type of RMA#?
If it is text, try this

sql = "SELECT * FROM [REPAIR] WHERE [RMA#] = '" & variable &"'"

One more thing, there should be a space between "&" and varable.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top