missinglinq
Programmer
Trying to help a friend with this, so I'm kind of stuck with some of the things here. He wants to goto a new record, enter a PtID then check to see if there's already a record for the data entered. It it already exits, he wants to cancel the new record and go to the existing record; if not he wants to be able to continue adding the new record. PtID is a text datatype.
The code below works fine if it's simply applied to an unbound textbox or when appied to the field itself, but the problem I'm having is cancelling the new record before going to the existing record. I've tried Me.Undo, Cancel = True, SendKeys "{ESC}" and combinations thereof. I've tried putting all of it in the Form_BeforUpdate with no joy. Any ideas would be welcomed. As I said, I'm stuck with the above scenario. IF I were doing it, I'd put a combobox on the form, check for a match and go to it or if no match then got a new record.
The Missinglinq
Richmond, Virginia
There's ALWAYS more than one way to skin a cat!
The code below works fine if it's simply applied to an unbound textbox or when appied to the field itself, but the problem I'm having is cancelling the new record before going to the existing record. I've tried Me.Undo, Cancel = True, SendKeys "{ESC}" and combinations thereof. I've tried putting all of it in the Form_BeforUpdate with no joy. Any ideas would be welcomed. As I said, I'm stuck with the above scenario. IF I were doing it, I'd put a combobox on the form, check for a match and go to it or if no match then got a new record.
Code:
Private Sub PtID_LostFocus()
intX = DCount("[PtID]", "ActivePatientsQuery", "[PtID]='" & Me![PtID] & "'")
If intX > 0 Then
[b]'Need to cancel record save here[/b]
Set rs = Me.Recordset.Clone
rs.FindFirst "[PtID] = '" & Me![PtID] & "'"
Me.Bookmark = rs.Bookmark
End If
End Sub
The Missinglinq
Richmond, Virginia
There's ALWAYS more than one way to skin a cat!