J
JohnLute
Per request I've started another thread regarding this puzzling issue.
I have a subform that creates a reciprocal record. Here's it's SQL (with
non-essential fields removed):
SELECT tblLocationsDestinations.LocationsDestinations,
tblLocationsDestinations.numLocationAddressID,
tblLocationsDestinations.TotalMiles
FROM tblLocationsDestinations;
Here's the subform's AfterUpdate event in question:
Private Sub Form_AfterUpdate()
With CurrentDb
' Delete the old destination, if it existed.
If Len(mstrOldDestinations) > 0 Then
mstrOldDestinations = Chr(34) & Me.cbLocationsDestinations.OldValue
& Chr(34)
.Execute _
"DELETE * FROM tblLocationsDestinations " & _
"WHERE LocationsDestinations=" & Me!numLocationAddressID & _
"AND numLocationAddressID=" &
Me.cbLocationsDestinations.OldValue, _
dbFailOnError
End If
' Create a reciprocal record to match the record being saved.
.Execute _
"INSERT INTO tblLocationsDestinations " & _
"(LocationsDestinations, numLocationAddressID) " & _
"VALUES (" & Me!numLocationAddressID & ", " & _
Me.cbLocationsDestinations & ")", _
dbFailOnError
End With
mstrOldDestinations = vbNullString
End Sub
Everything returns and works as expected EXCEPT when updating a reciprocal
record's TotalMiles field. This results in the deletion of the original
(parent record's) TotalMiles value.
In other words I create a record in tblLocationsDestinations and enter
TotalMiles. I go to the child record and enter its TotalMiles. I go back to
the parent record and its TotalMiles value has been deleted. I can add it
again but then the TotalMiles
for its child record is deleted.
Does anyone see why the TotalMiles records are affected like this? Is it
because
the subform is updating everything...?
I appreciate any help you might have!!!
I have a subform that creates a reciprocal record. Here's it's SQL (with
non-essential fields removed):
SELECT tblLocationsDestinations.LocationsDestinations,
tblLocationsDestinations.numLocationAddressID,
tblLocationsDestinations.TotalMiles
FROM tblLocationsDestinations;
Here's the subform's AfterUpdate event in question:
Private Sub Form_AfterUpdate()
With CurrentDb
' Delete the old destination, if it existed.
If Len(mstrOldDestinations) > 0 Then
mstrOldDestinations = Chr(34) & Me.cbLocationsDestinations.OldValue
& Chr(34)
.Execute _
"DELETE * FROM tblLocationsDestinations " & _
"WHERE LocationsDestinations=" & Me!numLocationAddressID & _
"AND numLocationAddressID=" &
Me.cbLocationsDestinations.OldValue, _
dbFailOnError
End If
' Create a reciprocal record to match the record being saved.
.Execute _
"INSERT INTO tblLocationsDestinations " & _
"(LocationsDestinations, numLocationAddressID) " & _
"VALUES (" & Me!numLocationAddressID & ", " & _
Me.cbLocationsDestinations & ")", _
dbFailOnError
End With
mstrOldDestinations = vbNullString
End Sub
Everything returns and works as expected EXCEPT when updating a reciprocal
record's TotalMiles field. This results in the deletion of the original
(parent record's) TotalMiles value.
In other words I create a record in tblLocationsDestinations and enter
TotalMiles. I go to the child record and enter its TotalMiles. I go back to
the parent record and its TotalMiles value has been deleted. I can add it
again but then the TotalMiles
for its child record is deleted.
Does anyone see why the TotalMiles records are affected like this? Is it
because
the subform is updating everything...?
I appreciate any help you might have!!!