I have a simple Append query which adds records to table3 when it finds matching records in table1 and table2.
In table1 and table2 there is a boolean field 'Matched' which I need to set to True whenever a match is found (to prevent processing a second time).
Is it possible to do this?
On the assumption that it *should* work I have adopted the following approach:
I have set a query field to
expr: SetMatched([table1].[AutonumId],[table2].[AutonumId])
to call the function, which is in the General module.
(code generalised)
Function SetMatched(lngTable1Id As Long, lngTable2Id As Long)
'
' when a match is found call this function
' to set the Matched boolean value to True
' in both tables
'
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim lngTab1 As Long
Dim lngTab2 As Long
lngTab1 = lngTable1Id
lngTab2 = lngTable2Id
Set db = CurrentDb
' Update Table1
Set rst = CurrentDb().OpenRecordset("Table1", dbOpenTable)
rst.Index = "AutonumId"
rst.Seek "=", lngTab1
rst![Matched] = True
rst.Update
rst.Close
Set rst = Nothing
'same repeated for the second table
End Function
===============
The query executes OK, no errors, but the function isn't called.
Any pointers to how this could be made to work OR to an alternative approach would be much appreciated.
In table1 and table2 there is a boolean field 'Matched' which I need to set to True whenever a match is found (to prevent processing a second time).
Is it possible to do this?
On the assumption that it *should* work I have adopted the following approach:
I have set a query field to
expr: SetMatched([table1].[AutonumId],[table2].[AutonumId])
to call the function, which is in the General module.
(code generalised)
Function SetMatched(lngTable1Id As Long, lngTable2Id As Long)
'
' when a match is found call this function
' to set the Matched boolean value to True
' in both tables
'
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim lngTab1 As Long
Dim lngTab2 As Long
lngTab1 = lngTable1Id
lngTab2 = lngTable2Id
Set db = CurrentDb
' Update Table1
Set rst = CurrentDb().OpenRecordset("Table1", dbOpenTable)
rst.Index = "AutonumId"
rst.Seek "=", lngTab1
rst![Matched] = True
rst.Update
rst.Close
Set rst = Nothing
'same repeated for the second table
End Function
===============
The query executes OK, no errors, but the function isn't called.
Any pointers to how this could be made to work OR to an alternative approach would be much appreciated.