J
Jani
Need some assistance on getting this coding to work right on this form.
Basically, if the location and date are already in the SQL table, the 'Date1'
and 'Location' fields need to be cleared on the form and the focus be in the
'Location' field. Here's my latest (but obviously not greatest) 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! I
must also confess that I have posted this to a couple other groups a few days
ago but never got an answer.
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.txtLocation.SetFocus
End If
End Sub
Basically, if the location and date are already in the SQL table, the 'Date1'
and 'Location' fields need to be cleared on the form and the focus be in the
'Location' field. Here's my latest (but obviously not greatest) 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! I
must also confess that I have posted this to a couple other groups a few days
ago but never got an answer.
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.txtLocation.SetFocus
End If
End Sub