syntax error? parameter querydefs

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • x taol

    #1

    syntax error? parameter querydefs



    Set qd = CurrentDb.Query Defs("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 ***
  • MGFoster

    #2
    Re: syntax error? parameter querydefs

    x taol wrote:
    >
    Set qd = CurrentDb.Query Defs("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:::mgf0 0 <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/AwUBRTgv9YechKq OuFEgEQL1xgCdEZ 18+GOVRMGPpDdp/mkYIReOUfAAoINz
    0ba04P5gsxehoru NSWh0O5bL
    =DYMY
    -----END PGP SIGNATURE-----

    Comment

    Working...