[AccessD] Query Problem

Geldart, Robert RGeldart at detma.org
Fri Jun 6 12:33:00 CDT 2003


Tim,

If trying to build an SQL string, you need to concatenate the pieces without
the line continuation indicator (_) as in:

sqlWSName = "SELECT DISTINCT qryInvItemWrkSht.worksheet, "
sqlWSName = sqlWSName & "qryInvItemWrkSht.worksheet_desc "
sqlWSName = sqlWSName & "FROM qryWrkSht INNER JOIN qryInvItemWrkSht "
sqlWSName = sqlWSName & "ON qryWrkSht.[Item Number] =
qryInvItemWrkSht.Item;"


If trying to show a single statement wrapped, I believe you use the
continuation marker, but drop the quotes:

sqlWSName = "SELECT DISTINCT qryInvItemWrkSht.worksheet, _
	qryInvItemWrkSht.worksheet_desc _
	FROM qryWrkSht INNER JOIN qryInvItemWrkSht _
	ON qryWrkSht.[Item Number] = qryInvItemWrkSht.Item;"

I think you may want the latter construction.


> -----Original Message-----
> From: Tim Thiessen [mailto:tim at irwin-greenhouses.com]
> Sent: Friday, June 06, 2003 12:00 PM
> Subject: [AccessD] Query Problem
> 
> Can anyone tell me what I am doing wrong here?  When I run 
> this as a stand alone query, it runs fine but when its in
> the form as code, I get the error message
> "Run-time error 3061 Too few parameters. Expected 1"
> 
> sqlWSName = "SELECT DISTINCT qryInvItemWrkSht.worksheet, " _
>     & "qryInvItemWrkSht.worksheet_desc " _
>     & "FROM qryWrkSht INNER JOIN qryInvItemWrkSht " _
>     & "ON qryWrkSht.[Item Number] = qryInvItemWrkSht.Item;"
> Set rstWSName = CurDb.OpenRecordset(sqlWSName)
> 
> Tim Thiessen


More information about the AccessD mailing list