I create a DAO.Recordset thus:
Set recJoined=MyDB.OpenRecordSet(" Select * From TableA Inner Join TableB On TableA.FieldA=TableB.FieldA")
The problem is that the Tables A and B have many fields, and some of them with the same name.
I now want to select a record with
recJoined.FindFirst FieldA="100"
This fails of course because ‘FieldA’ does not refer to a unique field.
However when I change the criteria to:
recJoined.FindFirst TableA.FieldA="100"
I run into a ‘unknown or invalid field reference’ error.
I could specify an alias for the TableA.FieldA field of course in the Select statement, but as I need all fields from TableA and TableB and they have a lot, that would be very cumbersome indeed.
How to solve this?
I upvoted Conrad’s answer, but I cannot accept it as it does not address my specific need: to be able to select all fields, without specifically knowing which these are, but being able to alias the Join column.
This is true of course, but the FindFirst statement does not see it so, it requieres a unique specifier
and raises an error.
The name simply is FieldA without any further qualifications or prefixes. So that does not help.
Yes it is! and this leads to the solution. But the resultset has the FieldA now twice: once with the Aliased name, once with the original name. The Aliased field is updatable, the original field not. Once I took care not to update the FieldA field all was fine.