Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004

    Unanswered: VBA code for running an updateable select query.

    Hi Folks,

    I have the following code:

    'Prepare the query
    Lookupstr = "SELECT TblExchRateMaster.YearsID, blah blah"
    Lookupstr = Lookupstr & "FROM TblPeriod INNER JOIN blah blah "
    Lookupstr = Lookupstr & "Where (((TblYears. blah blah"
    Lookupstr = Lookupstr & "ORDER BY TblExchRateMaster. blah blah;"

    'Execute the query
    CurrentDb.Execute Lookupstr

    The error I get is "Cannot execute Select query".

    I am able to make this work as a saved query and call it in a form by:

    DoCmd.OpenQuery stDocName, acNormal, acEdit

    ...but am not able to run it from code...

    Also tried the DoCmd with Lookupstr. It doesnt work.

    Thanks & Rgds,

  2. #2
    Join Date
    Aug 2003
    Delft, The Netherlands (EU)

    Re: VBA code for running an updateable select query.

    Depends on what you want to accomplish.

    to return a recordset:

    SET RS=CurrentDB.OpenRecordset(LockupString)
    Make everything as simple as possible, but not simpler! - A. Einstein
    DB Problems? DB Explorer, BTrieve Re-engineering, DB Conversions & ETL? Conversion Tool

  3. #3
    Join Date
    Nov 2003
    Maybe check your spacing (spaces) in Lookupstr. (??)

Posting Permissions

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