I'm trying to create a button inside of a Microsoft Access 2016 database for inventory tracking that, on click, displays an InputBox asking for the Serial Number, UDID, and/or IMEI of the device in question. I have an SQL query embedded in the private sub, code below:
Private Sub cmdInventoryItems_Click()
On Error Resume Next
Dim vItem As String
vItem = InputBox("Type the Serial Number/UDID/IMEI of your device.", "Text
Search")
Dim StrSQL As String
StrSQL = "Select * from tbl_Inventory where [Serial Number/UDID/IMEI] like
[%" & vItem & "%]"
Me.RecordSource = StrSQL
End Sub
The percentage signs inside the code are meant to allow the string to be compared to any piece of the Serial Number/UDID/IMEI field.
Whenever I click cmdInventoryItems it throws an InputBox, as planned, but when a value is input into the textbox, access asks for a parameter value with the prompt being the value I just entered surrounded by percentage symbols. If I type nothing into the "Enter parameter value" box everything disappears on my main form.
Can anyone explain what's going on, and how to fix it? Thanks for any help I can get.