M
mattc66 via AccessMonster.com
Hi All,
I have a form with a lookup box. The user types in the part number they want
to find. If they type in the wrong part number I want to be able to find the
next closest item. How would I do this?
This is the current code:
Private Sub LookUpItem_AfterUpdate()
Dim SID As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
SID = Me.LookUpItem.Value
stLinkCriteria = "[Item]=" & "'" & SID & "'"
'Check table for for item number.
If DCount("Item", "qryICStock_Combined", stLinkCriteria) >= 1 Then
'Go to record of original Number
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark
'If the item is not found the below code is run.
Else
'Message box warning that part number doesn't exsist.
msgbox "Item Not Found" _
& SID & " is not a valid part." _
& vbCr & vbCr & "Contact System Admin.", vbExclamation _
, "ITEM NOT FOUND"
End If
Set rsc = Nothing
Me.LookUpItem = Null
End Sub
I have a form with a lookup box. The user types in the part number they want
to find. If they type in the wrong part number I want to be able to find the
next closest item. How would I do this?
This is the current code:
Private Sub LookUpItem_AfterUpdate()
Dim SID As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
SID = Me.LookUpItem.Value
stLinkCriteria = "[Item]=" & "'" & SID & "'"
'Check table for for item number.
If DCount("Item", "qryICStock_Combined", stLinkCriteria) >= 1 Then
'Go to record of original Number
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark
'If the item is not found the below code is run.
Else
'Message box warning that part number doesn't exsist.
msgbox "Item Not Found" _
& SID & " is not a valid part." _
& vbCr & vbCr & "Contact System Admin.", vbExclamation _
, "ITEM NOT FOUND"
End If
Set rsc = Nothing
Me.LookUpItem = Null
End Sub