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

too few parameter, expected 1

Status
Not open for further replies.

stingers

Programmer
Joined
Jan 13, 2002
Messages
40
Location
US
whats wrogn with this code??? continue to get error listed in subject?? Making me crazy :(

refID is a text field

Set rst = CurrentDb.OpenRecordset("SELECT dbo_tblREF.* FROM dbo_tblREF WHERE (((dbo_tblREF.RefID)= col28));")

thanks in advance

ryan paul
 
What is col28? Most likely, SQL isn't recognizing that name, and is treating it as a parameter. Rick Sprague
 
If ColID is the actual text in the field, you'll need quotes around it. Use single quotes when writing SQL in code.
(dbo_tblREF.RefID)= 'col28'
 
It depends on the field type on what surrounds the value. For a text string itll be as you say quotes, I fits numeric its fine on it`s own but if it`s a date it needs the # symbols either side of the value.

I`ll agree though that this may be the reason for the error in this case if my memory serves me correctly.

Ian
 
***UPDATE TO ORIGINAL POST*****

HERE IS ALL THE CODE


Dim strStatus As String
Dim strMsg As String
Dim rst As Recordset


strStatus = Me.cboStatus

Set rst = CurrentDb.OpenRecordset("SELECT dbo_tblREF.* FROM dbo_tblREF WHERE (((dbo_tblREF.RefID)= " & strStatus & ";")


as an example strStatus could be Col28. I have tried to put single quotes (') inside the double quoted part of the select statement. The error i get is

Run Time error '3075'

Syntax Error in query expression '(((dbo_tblREF.RefID)='col28';'

or

Syntax Error in query expression '(((dbo_tblREF.RefID)=col28;'


thanks in advance
 
You need the single quotes. You also have unbalanced parentheses. Rick Sprague
 

Try this SQL. Added the ' marks eithier side of the strStatus plus addded adjusted the () to balance i think.

----------------------------------------------
Set rst = CurrentDb.OpenRecordset("SELECT dbo_tblREF.* FROM dbo_tblREF WHERE (((dbo_tblREF.RefID)= '" & strStatus & "'))")
----------------------------------------------

Hope this works

Ian

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top