How to Create Table Relationships in VBA

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

This is my first post and I would be grateful for any help! I am writing
some VBA code to initialize a report (using Access 2002, ADO). The report is
based on a query with multiple tables. One table needs to be dynamically
joined to another table using VBA before I open the report. Is there an easy
way to do this? It seems like there should be but I can't find any help on
this at all.

(FYI: The reason the table needs to be joined using code is that it is
created by a summary query which may be grouped by different fields, as
requested by the user. Thus the "group by" field needs to be linked to any
one of several fields in the query, depending on which field is being
summarized.)

Thank you in advance for any help!
 
Sure - use a SQL JOIN, for example:

SELECT DISTINCTROW [Last Name], [First Name]
FROM tblCustomers INNER JOIN tblInvoices
ON tblCustomers.CustomerID = tblInvoices.CustomerID
 
Back
Top