G
Graeme Richardson
Hi Bob, try the code in a the Form_BeforeUpdate event. Note that update is
cancelled if criteria not met
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Nz(txtFrom) = "" Or Nz(txtTo) = "" Then
Cancel = True
MsgBox ("You must have a 'From' and 'To' filled in.")
Else
txtDist = Abs(DLookup("Distance", "Locations", "Location = '" &
Me!txtTo & "'") - _
DLookup("Distance", "Locations", "Location = '" & Me!txtFrom &
"'"))
End If
End Sub
Hope this helps, Graeme
cancelled if criteria not met
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Nz(txtFrom) = "" Or Nz(txtTo) = "" Then
Cancel = True
MsgBox ("You must have a 'From' and 'To' filled in.")
Else
txtDist = Abs(DLookup("Distance", "Locations", "Location = '" &
Me!txtTo & "'") - _
DLookup("Distance", "Locations", "Location = '" & Me!txtFrom &
"'"))
End If
End Sub
Hope this helps, Graeme