• Parameter CreateQueryDef (Win XP Office 2003)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Parameter CreateQueryDef (Win XP Office 2003)

    Author
    Topic
    #455997

    OldIDCarnet is a variable set elsewhere in the code. What I have here puts the variable name as a literal in the query, not the data it contains. I looked at your example in 264717, but couldn’t get that to function. Where am I going wrong, please?

    ‘ execute query to change IDCarnetOld to IDCarnet, the new ID.
    strSQL = “SELECT tblSumaPorFacturaHistoria.IdCarnet INTO TestVBAQry FROM tblSumaPorFacturaHistoria WHERE (((tblSumaPorFacturaHistoria.IdCarnet)=OldIDCarnet));”
    Set qdf = dbs.CreateQueryDef(“”, strSQL)

    Viewing 0 reply threads
    Author
    Replies
    • #1137627

      If OldIDCarnet is a number then you should use :

      strSQL = “SELECT tblSumaPorFacturaHistoria.IdCarnet INTO TestVBAQry FROM tblSumaPorFacturaHistoria WHERE (((tblSumaPorFacturaHistoria.IdCarnet)=” & OldIDCarnet & “));”

      If OldIDCarnet is text then you should use :

      strSQL = “SELECT tblSumaPorFacturaHistoria.IdCarnet INTO TestVBAQry FROM tblSumaPorFacturaHistoria WHERE (((tblSumaPorFacturaHistoria.IdCarnet)=” & Chr(34) & OldIDCarnet & Chr(34) & “));”

    Viewing 0 reply threads
    Reply To: Parameter CreateQueryDef (Win XP Office 2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: