There is still very little information in your post. However, to answer what I think you are asking, you can set the recordsource of the current form to SQL built as a string value within the On Load event of the form like this - bearing in mind that I do not know the names of your linked tables or their fields, nor how many tables you want to use in your code, so I cannot use real field and table names in the example below:
- Dim strSQL as String
-
strSQL = "SELECT [field1], [field2], ... , [fieldn] "
-
strSQL = strSQL & " FROM [linked table] INNER JOIN [another table] "
-
strSQL = strSQL & " ON [linked table].[some field] = [another table].[some field];"
-
Me.Recordsource = strSQL
The Me operator is a shorthand way of referring to the current form in this case.
I would advise building Access queries using the query editor and using these as the record source for your form instead. You can also assign the relevant query dynamically as the recordsource for your form in the On Load event if you wish, like this
- IF somecondition THEN
-
Me.Recordsource = "[Query1]"
-
else
-
Me.Recordsource = "[Query2]"
-
end if
-Stewart