Link to home
Start Free TrialLog in
Avatar of spoowiz
spoowizFlag for United States of America

asked on

How to access field with same name from 2 tables

Hi,
I have the following code:

    sSel = "SELECT * FROM T1, T2"
    rst.Open sSel, cnACL, adOpenKeyset, adLockOptimistic

Both T1 and T2 tables have an objid field.
I can access all the fields from T1 and T2 using rst!field format. However, when I try to access T1!objid, I get an error msg stating that "orndinal cannot be found". I figure it must be because objid exists in both tables and I need a special syntax. How can I access T1!objid?

Thanks
Avatar of spoowiz
spoowiz
Flag of United States of America image

ASKER

oops. should be:
    sSel = "SELECT * FROM T1, T2" _
              & " WHERE T1.objid = T2.objidT1"
    rst.Open sSel, cnACL, adOpenKeyset, adLockOptimistic
ASKER CERTIFIED SOLUTION
Avatar of EDDYKT
EDDYKT
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
There is a typo in spoowiz code:
  sSel = "SELECT * FROM T1, T2  WHERE T1.objid = T2.objid"       ' Delete trailing 'T1'