[AccessD] Query Problem

Tim Thiessen tim at irwin-greenhouses.com
Fri Jun 6 14:37:18 CDT 2003


Robert,

I tried both of your suggestions but neither worked.  I was able to make it
work using a saved query and calling a QueryDef but that's not exactly what
I wanted to do.

Tim

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
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list