Need some assistance on getting this coding to work right. Basically, if the date entered in the 'Location' and 'Date1' fields is already in the SQL table, I want the two fields to be cleared out and the focus be set back at the 'Location' field. Here's my latest code which is giving a RunTime 2108 error 'Save the field before you execute the GoToControl action... or the SetFocus method.' Thanks so much in advance!



Private Sub txtDate1_BeforeUpdate(Cancel As Integer)
If Not IsNull(DLookup("[Date1]", "dbo_uSus_ActualData", "[Date1] = '" & Me.txtDate1 & "' And [Location] = '" & Me.txtLocation & "'")) Then
MsgBox "Some or all of the data for this date and location are already in the SQL table. Use the 'Edit Monthly Data for Selected Location' button on the right to enter additional data or edit data for this month and location."
Me.Undo

Cancel = True
Me.txtDate1.SetFocus
Me.txtLocation.SetFocus

End If

End Sub