Results 1 to 2 of 2
  1. #1
    4 Star Lounger
    Join Date
    Apr 2001
    Location
    Guatemala City
    Posts
    515
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Parameter CreateQueryDef (Win XP Office 2003)

    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)

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Parameter CreateQueryDef (Win XP Office 2003)

    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) & "));"
    Francois

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •