Results 1 to 3 of 3

Thread: Run query from module

  1. #1

    Thread Starter
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Run query from module

    I've created and save a query within Access and want to run it from within one of my modules. I have searched but can't find how to call it.

    Can anyone help?

  2. #2
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    Re: Run query from module

    DoCmd.OpenQuery "your_queryname_here"
    Tengo mas preguntas que contestas

  3. #3
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: Run query from module

    Salvelinus' method is one of many.

    If you know the SQL then you can do just.. (This is the more efficient method)

    VB Code:
    1. CurrentDb.Execute "SQL String"

    or you can pull the SQL from the query and then run it..

    VB Code:
    1. CurrentDb.Execute CurrentDb.QueryDefs("Query Name").SQL

    As a note always use CurrentDb.Execute in favour of DoCmd.RunSQL, especially when performing action query's as this removes the need to suppress confirmation messages generated by the DoCmd.RunSQL method, and it is more efficient.
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

Posting Permissions

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



Click Here to Expand Forum to Full Width