S
sneagle
I have a pop-up form for finding a code to enter on a main form. That
process works fine. However, I want the user to have the ability to enter a
new code into the underlying 'codes' table. The codes are numeric. After
the user enters a new code, if that code exists already, I want to stop them
and take them to that record. Below is the code I am using. The cancel
seems to work, then I get
"Run time error '2108' You must save the field before you execute the
GoToControl action, the GoToControl method or the SetFocus method."
Any suggestions?
Thanks.
Private Sub ICD9_beforeUpdate(Cancel As Integer)
Dim DuplicateICD9
If DCount("ICD9", "ICD9Codes", "[ICD9] = '" & Me.ICD9 & "'") > 0 Then
DuplicateICD9 = Me.ICD9
Cancel = True
MsgBox ("Already in use: " & DuplicateICD9)
Me.Undo
strFiltre = "([ICD9] + ""*"")"
DoCmd.ApplyFilter FilterName:=strFiltre
Me.ICD9.SetFocus
DoCmd.FindRecord DuplicateICD9, acAnywhere
End If
End Sub
process works fine. However, I want the user to have the ability to enter a
new code into the underlying 'codes' table. The codes are numeric. After
the user enters a new code, if that code exists already, I want to stop them
and take them to that record. Below is the code I am using. The cancel
seems to work, then I get
"Run time error '2108' You must save the field before you execute the
GoToControl action, the GoToControl method or the SetFocus method."
Any suggestions?
Thanks.
Private Sub ICD9_beforeUpdate(Cancel As Integer)
Dim DuplicateICD9
If DCount("ICD9", "ICD9Codes", "[ICD9] = '" & Me.ICD9 & "'") > 0 Then
DuplicateICD9 = Me.ICD9
Cancel = True
MsgBox ("Already in use: " & DuplicateICD9)
Me.Undo
strFiltre = "([ICD9] + ""*"")"
DoCmd.ApplyFilter FilterName:=strFiltre
Me.ICD9.SetFocus
DoCmd.FindRecord DuplicateICD9, acAnywhere
End If
End Sub