G
Guest
A couple years ago Dirk helped me with the challenge of creating reciprocal
records in a table. The following is based off his AfterUpdate code which has
always worked. I've modified it slightly for use in another function which
also requires reciprocal records. Except for the field name and table name
changes it's EXACTLY per Dirk's code:
Private Sub Form_AfterUpdate()
With CurrentDb
' Delete the old destination, if it existed.
If Len(mstrOldDestinations) > 0 Then
.Execute _
"DELETE * FROM tblLocationsDestinations " & _
"WHERE LocationsDestinations='" & Me!numLocationAddressID & "' " & _
"AND numLocationAddressID=" & mstrOldDestinations
End If
' Create a reciprocal record to match the record being saved.
.Execute _
"INSERT INTO tblLocationsDestinations " & _
"(LocationsDestinations, numLocationAddressID) " & _
"VALUES ('" & Me!numLocationAddressID & "', '" &
Me.cbLocationsDestinations & "')"
End With
mstrOldDestinations = vbNullString
End Sub
The problem is that I can create a record but the reciprocal record isn't
reciprocating! I get no error messages - it just doesn't create the
reciprocal record. Is it because in this new function the primary key field
is a number data type? In my other function the primary key field is a text
data type - that's the only difference I see.
If that's the case do I need to change my closing quotation marks?
Thanks a bunch - gobble, gobble!
records in a table. The following is based off his AfterUpdate code which has
always worked. I've modified it slightly for use in another function which
also requires reciprocal records. Except for the field name and table name
changes it's EXACTLY per Dirk's code:
Private Sub Form_AfterUpdate()
With CurrentDb
' Delete the old destination, if it existed.
If Len(mstrOldDestinations) > 0 Then
.Execute _
"DELETE * FROM tblLocationsDestinations " & _
"WHERE LocationsDestinations='" & Me!numLocationAddressID & "' " & _
"AND numLocationAddressID=" & mstrOldDestinations
End If
' Create a reciprocal record to match the record being saved.
.Execute _
"INSERT INTO tblLocationsDestinations " & _
"(LocationsDestinations, numLocationAddressID) " & _
"VALUES ('" & Me!numLocationAddressID & "', '" &
Me.cbLocationsDestinations & "')"
End With
mstrOldDestinations = vbNullString
End Sub
The problem is that I can create a record but the reciprocal record isn't
reciprocating! I get no error messages - it just doesn't create the
reciprocal record. Is it because in this new function the primary key field
is a number data type? In my other function the primary key field is a text
data type - that's the only difference I see.
If that's the case do I need to change my closing quotation marks?
Thanks a bunch - gobble, gobble!