By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,335 Members | 2,718 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,335 IT Pros & Developers. It's quick & easy.

syntax error? parameter querydefs

P: n/a


Set qd = CurrentDb.QueryDefs("qsXX")
qd.Parameters("parDt") = "#9/1/2006#"
With Me.subFom.Form
.RecordSource = qd.SQL
.Requery
End With

in that case, parameter dialog box appear. why?
what's wrong?

*** Sent via Developersdex http://www.developersdex.com ***
Oct 19 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
x taol wrote:
>
Set qd = CurrentDb.QueryDefs("qsXX")
qd.Parameters("parDt") = "#9/1/2006#"
With Me.subFom.Form
.RecordSource = qd.SQL
.Requery
End With

in that case, parameter dialog box appear. why?
what's wrong?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You've created an instance of the QueryDef and then set that instance's
parameter. Then you've taken only the QueryDef's SQL and put it into
the RecordSource of the form. That SQL still has the parameter line
("PARAMETERS parDT Date;") without the value because the QueryDef holds
the parameter value, not the SQL string.

You could just do a Replace() to get rid of the PARAMETERS line and
substitute the date value for the parameter name. E.g.:

strSQL = Replace(qd.SQL,"PARAMETERS parDt DateTime;","")
Me!subForm.Form.RecordSource = Replace(strSQL, "parDT","#9/1/2006#")

You don't have to Requery 'cuz changing the RecordSource automatically
does that.
--
MGFoster:::mgf00 <atearthlink <decimal-pointnet
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBRTgv9YechKqOuFEgEQL1xgCdEZ18+GOVRMGPpDdp/mkYIReOUfAAoINz
0ba04P5gsxehoruNSWh0O5bL
=DYMY
-----END PGP SIGNATURE-----
Oct 20 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.