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

Select Query Too Few Parameters. Expected 3 1

Status
Not open for further replies.

loydlr

Technical User
Mar 4, 2002
34
RU
I'm pretty clueless at this stuff, but I've managed to put together a query (just can't manage to make it work). Any suggestions would be greatly appreciated.

strSQL = "SELECT DISTINCT tblContractDetails.ContractDetailsID, tblGradingSheet.ContractName, tblGradingSheet.Source" & _
" FROM tblContractDetails INNER JOIN tblGradingSheet ON tblContractDetails.ContractDetailsID = tblGradingSheet.ContractDetailsID" & _
" WHERE tblGradingSheet.ContractName = " & Forms!frmRawProductGradingPeas!subfrmGradingSheet.Form!txtContractName & " AND" & _
" tblGradingSheet.Source = " & Forms!frmRawProductGradingPeas!subfrmGradingSheet.Form!txtSource

I'm trying to get the value of the ContractDetailsID, but every time I run this sub I get the error: Too few parameters. Expected 3
 
WHERE tblGradingSheet.ContractName = " & Forms!frmRawProductGradingPeas!subfrmGradingSheet.Form!txtContractName & "

If you are referring to text values in a query you need to surround them with sing quotes. So something like

" WHERE tblGradingSheet.ContractName = '" & Forms!frmRawProductGradingPeas!subfrmGradingSheet.Form!txtContractName & "' AND ...

so that you answer resolves to something like

" WHERE tblGradingSheet.ContractName = 'ContractABC' And ... = 'GradingSheet Source XYZ'
 
PS. If it returns a numeric value then no single quotes. If it returns a date then it needs # surrounding your returned value. Something like

where tblGradingSheetDate = #1/1/2009#
 
Thank you so much for the help. It works perfectly now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top