N
NEWER USER
I have an Unbound text box on a form that searches my database for exact
matches. On After Update Event, it moves the focus to NumberID and if a
match is found, displays the record on the form. If no match, Microsoft
Access displays a message stating that "You can not go to the specified
record". If No record is found, I would like to open another form and
display the CLOSEST MATCH(s). For instance, I search 1234ABC and it does not
exist. However, 1234A does exist. I want to show this record as a possible
choice. This where I need some help. So far I have the following code and it
works very quick when searching. Any help appreciated.
Private Sub Search_AfterUpdate()
On Error GoTo Search_AfterUpdate_Err
With CodeContextObject
Me!Search = Replace(Me!Search, " ", "")
Me!Search = Replace(Me!Search, "-", "")
Me!Search = Replace(Me!Search, ".", "")
Me!Search = Replace(Me!Search, "/", "")
DoCmd.GoToControl "NumberID"
DoCmd.FindRecord .Search, acEntire, False, , False, , True
End With
Search_AfterUpdate_Exit:
Exit Sub
Search_AfterUpdate_Err:
MsgBox Err.Description
Resume Search_AfterUpdate_Exit
End Sub
matches. On After Update Event, it moves the focus to NumberID and if a
match is found, displays the record on the form. If no match, Microsoft
Access displays a message stating that "You can not go to the specified
record". If No record is found, I would like to open another form and
display the CLOSEST MATCH(s). For instance, I search 1234ABC and it does not
exist. However, 1234A does exist. I want to show this record as a possible
choice. This where I need some help. So far I have the following code and it
works very quick when searching. Any help appreciated.
Private Sub Search_AfterUpdate()
On Error GoTo Search_AfterUpdate_Err
With CodeContextObject
Me!Search = Replace(Me!Search, " ", "")
Me!Search = Replace(Me!Search, "-", "")
Me!Search = Replace(Me!Search, ".", "")
Me!Search = Replace(Me!Search, "/", "")
DoCmd.GoToControl "NumberID"
DoCmd.FindRecord .Search, acEntire, False, , False, , True
End With
Search_AfterUpdate_Exit:
Exit Sub
Search_AfterUpdate_Err:
MsgBox Err.Description
Resume Search_AfterUpdate_Exit
End Sub