Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Aug 2002
    Location
    New Jersey, USA
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    update query (97 sr2)

    Good morning,

    I want to run a query from a function, can you help me with the code?

    This is what I have

    Set dbs = OpenDatabase(NFSPath)
    Set rst = dbs.openrecordset("Kirchman_full", dbopendynaset)

    the query I want to run is in the database and it is called
    Qry:_Check_92_Accounts
    It is an update query if that makes any difference.

    I think there is a way to do this with dbs.execute but I am not sure of the exact syntex.


    Thanks again for all your help

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: update query (97 sr2)

    There are two possible ways to do this:

    dbs.Execute "Qry:_Check_92_Accounts"

    or

    Dim qdf As DAO.QueryDef
    Set qdf = dbs.QueryDefs("Qry:_Check_92_Accounts")
    qdf.Execute

    (The recordset doesn't come into this)

  3. #3
    2 Star Lounger
    Join Date
    Aug 2002
    Location
    New Jersey, USA
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: update query (97 sr2)

    On thing I forgot to say,
    I queries and the table that is going to be updated is in a different database than the function.

    do I still use the same syntex.

    Thanks

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: update query (97 sr2)

    Since you open the database using

    Set dbs = OpenDatabase(...)

    everything you do with dbs will refer to and act on the tables and queries in that database. You can use the syntax I posted in my previous reply.

Posting Permissions

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