Results 1 to 3 of 3

Thread: DAO - Two tables at once

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    ma,usa
    Posts
    485
    Hi Everyone!
    Could someone help me out with learning this?
    I am using DAO. I'm using this code to open a database and select a table to work with:

    Set db = OpenDatabase ("C:\db2")
    ' open up the dynaset
    Set rs = db.OpenRecordset("TableName1", dbOpenDynaset)

    This works great. Now I want to open two tables just like when using recordsource with datacontrol:

    strSQL = "Select * from _ TableName1,TableName2 _
    where TableName1.Id_num = Table2.Id_num"
    Set db = OpenDatabase ("C:\db2")
    ' open up the dynaset
    Set rs = db.OpenRecordset strSQL, dbOpenDynaset)

    This doesn't work great

    Any Code or Help is really appreciated!

    Thanks Again,
    Joey O

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    Change your select statement to this:

    Select * from TableName1 Inner Join TableName2 On _
    TableName1.Id_num = Table2.Id_num


    Also, you have to be sure that those 2 tables related, I mean that they have common Id_num values.

    [Edited by Serge on 04-13-2000 at 11:18 AM]

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    ma,usa
    Posts
    485
    That was fast! Thanks Surge, I'm so glad you could help me. Someday I hope I can help you too!
    Joey O

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