Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Refering to fields in a recordset
Message
 
To
28/04/2000 04:14:14
General information
Forum:
Visual Basic
Category:
Database DAO/RDO/ODBC/ADO
Miscellaneous
Thread ID:
00364366
Message ID:
00364382
Views:
26
>I have a recordset based on an SQL query, it includes more than one table. How do I refer to this in code?
>
>In the past I have only used recordsets consiting of one table and so I have used the sytanx
>
>recordsetname!fieldname
>
>but there could be more than one field with the same name in the recordset that I am using now, but from different tables,
>
>I tried
>
>recordsetname!tablename.fieldname and
>recordsetname!tablename!fieldname
>
>but had no luck with either.
>
>Can someone help please?

A recordset can't contain 2 fields with the same name. You have to use aliases to make them unique. The syntax is the following:
SELECT A.ID as ID1, B.ID as ID2, A.LName
FROM A, B
WHERE ...
Now in your application, you have to use aliases (if aliases are given) instead of the real field name.
recordsetname!ID1
recordsetname!ID2
recordsetname!LName
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform