M
mattc66 via AccessMonster.com
Hi All,
I have a combo box that I'd like to use 2 ways.
1) Look Up Data in external table and populate form with data found. I got
this to work just fine.
Its the second way that I need help with:
2) If the data typed is not found in Combo Box I'd like to check the table
associated with main form and see if the it already exsists. If it finds the
data then it would take the user to that record.
See the code I placed in my NOT IN LIST event it doesn't seem to work. I get
a message "INVALID USE OF NULL"
Private Sub LookUpOrder_NotInList(NewData As String, Response As Integer)
On Error GoTo Err_LookUpOrder_NotInList
'Message box warning that order doesn't exsist.
Dim SID As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
SID = Me.LookUpOrder.Value
stLinkCriteria = "[OrderNum]=" & "'" & SID & "'"
'Check table for for item number.
If DCount("OrderNum", "tblShip", stLinkCriteria) >= 1 Then
'Go to record of original Number
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark
Else
Msgbox "Order Number" _
& SID & " is not valid order number," _
& vbCr & vbCr & "check the number and try again." _
& vbCr & vbCr & "If the order is still not found" _
& vbCr & vbCr & "contact order entry.", vbExclamation _
, "ORDER NOT FOUND"
End If
Me.TrackingNum.SetFocus
Set rsc = Nothing
Me.LookUpOrder = Null
Exit_LookUpOrder_NotInList:
Exit Sub
Err_LookUpOrder_NotInList:
Msgbox Err.Description
Resume Exit_LookUpOrder_NotInList
End Sub
I have a combo box that I'd like to use 2 ways.
1) Look Up Data in external table and populate form with data found. I got
this to work just fine.
Its the second way that I need help with:
2) If the data typed is not found in Combo Box I'd like to check the table
associated with main form and see if the it already exsists. If it finds the
data then it would take the user to that record.
See the code I placed in my NOT IN LIST event it doesn't seem to work. I get
a message "INVALID USE OF NULL"
Private Sub LookUpOrder_NotInList(NewData As String, Response As Integer)
On Error GoTo Err_LookUpOrder_NotInList
'Message box warning that order doesn't exsist.
Dim SID As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
SID = Me.LookUpOrder.Value
stLinkCriteria = "[OrderNum]=" & "'" & SID & "'"
'Check table for for item number.
If DCount("OrderNum", "tblShip", stLinkCriteria) >= 1 Then
'Go to record of original Number
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark
Else
Msgbox "Order Number" _
& SID & " is not valid order number," _
& vbCr & vbCr & "check the number and try again." _
& vbCr & vbCr & "If the order is still not found" _
& vbCr & vbCr & "contact order entry.", vbExclamation _
, "ORDER NOT FOUND"
End If
Me.TrackingNum.SetFocus
Set rsc = Nothing
Me.LookUpOrder = Null
Exit_LookUpOrder_NotInList:
Exit Sub
Err_LookUpOrder_NotInList:
Msgbox Err.Description
Resume Exit_LookUpOrder_NotInList
End Sub