Form's Record source

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • questionit
    Contributor
    • Feb 2007
    • 553

    Form's Record source

    Hi

    It it possible to have more than 1 tables to be the Record Source of a form ?

    If yes, how could it be done ?

    I have tried relating 2 forms with primary key but this way only one table's fields becomes available to the form !


    Thanks
    Qi
  • Stwange
    Recognized Expert New Member
    • Aug 2007
    • 126

    #2
    Originally posted by questionit
    Hi

    It it possible to have more than 1 tables to be the Record Source of a form ?

    If yes, how could it be done ?

    I have tried relating 2 forms with primary key but this way only one table's fields becomes available to the form !


    Thanks
    Qi
    You could remove the record source entirely (or have one form as the recordsource to fill in its share of the fields). Then for the other records, do:
    Dim rs as DAO.recordset
    set rs = DBEngine(0)(0). openRecordSet(" SELECT * FROM table1 INNER JOIN table2 ON table1.somefiel d = table2.somefiel d WHERE someprimarykey = '"& txtprimarykey.v alue & "';") 'fill in field names as appropriate

    You can then refer to each field from the join as a field of the recordset. Eg. if you field is called name, rs!name, so txtName.value = rs!name etc.

    Hope this helps.

    Comment

    Working...