Searching Access fields using Variables

alfboy50
10-24-2004, 03:20 PM
Hey Guys, I have another problem for you to solve. I have a variable called StuChoice. It is created on one form but I am calling it on the next. The value carries over so I know it isn't a problem with that. But anyway I want to use the variable to query my Access 2002 database like so:

Set test = DataB.Openrecordset("Select * from [Login] where [FullName] = StuChoice")

However it is giving me an error that says too few parameters. There is a record in the table that matches the variable though so I don't see what the problem is. If someone else does that please tell me what it is. I have a feeling that it is something to do with the = StuChoice part but I don't know for sure. I appreciate the help. thanks.

webbone
10-24-2004, 03:23 PM
Hey Guys, I have another problem for you to solve. I have a variable called StuChoice. It is created on one form but I am calling it on the next. The value carries over so I know it isn't a problem with that. But anyway I want to use the variable to query my Access 2002 database like so:

Set test = DataB.Openrecordset("Select * from [Login] where [FullName] = StuChoice")

However it is giving me an error that says too few parameters. There is a record in the table that matches the variable though so I don't see what the problem is. If someone else does that please tell me what it is. I have a feeling that it is something to do with the = StuChoice part but I don't know for sure. I appreciate the help. thanks.
Assuming StuChoice is the variable you are wanting to use:

Set test = DataB.Openrecordset("Select * from [Login] where [FullName] = '" & StuChoice & "'")

If the field is numeric rather than string then leave out the single quotes.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum