Results 1 to 3 of 3
  1. #1
    RyanS
    Guest

    Query Specific Table

    If I have multiple tables in a database and want to run the same query on each table individually, how do I do this. I have had to remove all other tables from the query so that only the one I want the query to work on was left.
    I'd also be interested in finding out how I could change the table choice in multiple queries, in the same database, at the same time. It is a pain to go into each query and change the table it is working from. If anyone has any suggestions I would be very grateful.
    <img src=/S/doh.gif border=0 alt=doh width=15 height=15>

  2. #2
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    The Netherlands
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Query Specific Table

    You can try it using VBA and making the query dynamically like this:

    dim strFields as string
    dim strTable as string
    dim strOther as string
    dim strSQL as string

    strFields = "SELECT fld1, fld2, fld3 "
    strFrom = "FROM tblYourTable "
    strOther = "WHERE ..... ORDER BY .."

    strSQL = strFields & strFrom & strOther & ";"

    Now you can execute the SQL or use it to define a recordset.
    If you have multiple tabels you can program a loop to generate a SQL string for each table you want a query for.

  3. #3
    RyanS
    Guest

    Re: Query Specific Table

    Thanks for the info Bart. I'll do some experimenting and see if I can make it work.

    RyanS

Posting Permissions

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