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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Access select with a variable

Status
Not open for further replies.

srmcmains

Programmer
May 15, 2003
9
US
Progress 9.1B

I am trying to use a select in progress that would check a variable instead of a constant.

Here is what I have:

def var project-id as int.

project-id = 2.

Assign ODBC-DSN = "PCDB"
ODBC-SERVER = "localhost"
OBDC-Userid = ""
ODBC-PASSWD = ""
ODBC-QUERY = "select tbltime.nProjectID
from tbltime
where tbltime.nprojectid = :project-id".

I am getting an error "Error occurred while accessing component property/method: OPEN. [Microsoft} {ODBC Microsoft Access Driver] Too few parameters. Expected 1. Error code: 0x0020009 (5890).

How would you code it to be able to see a variable instead of a constant or table field name? Any help would be appreaciated.

Thanks, Shawnna McMains
 
Assuming the rest of your syntax is correct, change the last line to:

where tbltime.nprojectid = :" + string(project-id).
 
Stanhubble,

Thanks for the reply, but it still gives me the same error. If I put a actual constant in there it works fine, which tells me all the syntax is correct, just doesn't want to allow me to use a variable. Any other suggestions would be helpful.
 
Omit the colon--that's what makes it think you have a parameter following.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top