Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2003
    Location
    Planet Earth
    Posts
    8

    Unanswered: Running two queries with one button

    How can I run two queries with the same button in Access?

  2. #2
    Join Date
    Oct 2001
    Location
    Chicago
    Posts
    440
    Just duplicate your code and change the query name:

    ' OpenQuery method

    Dim stDocName As String

    stDocName = "Query1"
    DoCmd.OpenQuery stDocName, acNormal, acEdit

    stDocName = "Query2"
    DoCmd.OpenQuery stDocName, acNormal, acEdit

    'or the Execute method of the QueryDef object

    Dim qry As QueryDef
    Set qry = CurrentDb.QueryDefs("Query1")

    ' Optional Paramenters
    qry.Parameters![Param1] = "First Param"
    qry.Parameters![Param2] = "Second Param"
    ' ...
    ' Execute the query and fail on an error
    qry.Execute dbFailOnError

    ' Repeat
    Set qry = CurrentDb.QueryDefs("Query2")
    qry.Execute dbFailOnError

Posting Permissions

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