I have a search box on one form that finds records by OrderID (ex 305321) on a checkout and ordering form and a second that I just added to a form to look up flooring products that searches the FLID value (ex FLID00005) the second however will only return a new record even when the data that I am searching for exists and when I use the enter functionality on it it asks for a parameter value which if I enter the same value that is in the search box it runs properly.
The code for the Orders search form:
Private Sub cmdFindbyOID_Click()
If IsNull([FindByOIDSearchBox]) Then
MsgBox "You must Enter a Order ID", vbInformation, "Error"
Exit Sub
End If
Me.Filter = "(([Orders In Progress Query].OrderID = " & FindByOIDSearchBox & "))"
Me.FilterOn = True
Me.[Orders All Details Subform].Requery
End Sub
Private Sub FindByOIDSearchBox_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
cmdFindByOID.SetFocus
If IsNull([FindByOIDSearchBox]) Then
MsgBox "You must Enter a Order ID", vbInformation, "Error"
Exit Sub
End If
Me.Filter = "(([Orders In Progress Query].OrderID = " & FindByOIDSearchBox & "))"
Me.FilterOn = True
Me.[Orders All Details Subform].Requery
End If
End Sub
The code for the flooring products form:
Private Sub cmdFindbyFLID_Click()
If IsNull([findByFLIDSearchBox]) Then
MsgBox "You must Enter a Flooring ID", vbInformation, "Error"
Exit Sub
End If
Me.Filter = "(([Flooring Products Query].FLID = " & findByFLIDSearchBox & "))"
Me.FilterOn = True
End Sub
Private Sub FindByFLIDSearchBox_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
cmdFindbyFLID.SetFocus
If IsNull([findByFLIDSearchBox]) Then
MsgBox "You must Enter a Flooring ID", vbInformation, "Error"
Exit Sub
End If
Me.Filter = "(([Flooring Products Query].FLID = " & findByFLIDSearchBox & "))"
Me.FilterOn = True
End If
End Sub
FLID contains characters. Therefore, your reference needs to be inside a single quote.
Me.Filter = "(([Flooring Products Query].FLID = '" & findByFLIDSearchBox & "'))"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.