J
Jeff via AccessMonster.com
I have a search button on my form that sets the recordsource to a new
recordset based on the search criteria. My problem is that if the search
returns no records then I get an error message. To get around this I'll
have to check if the recordset is null before I set it. Unfortunately, I
can't seem to get it working. Here's the code that works without null
recorsets. Can someone help me insert the null check into this code.
Thanks,
Dim IDCheck, SQLString AS String
IDCheck = InputBox("Please enter the Case ID you wish to search for.",
"Search", "")
If IDCheck = "" Then
'No value entered or cancel was clicked
Exit Sub
Else
'Search for ID
SQLString = "SELECT * FROM Table WHERE [ID] = "& IDCheck
Me.RecordSource = SQLString
End If
recordset based on the search criteria. My problem is that if the search
returns no records then I get an error message. To get around this I'll
have to check if the recordset is null before I set it. Unfortunately, I
can't seem to get it working. Here's the code that works without null
recorsets. Can someone help me insert the null check into this code.
Thanks,
Dim IDCheck, SQLString AS String
IDCheck = InputBox("Please enter the Case ID you wish to search for.",
"Search", "")
If IDCheck = "" Then
'No value entered or cancel was clicked
Exit Sub
Else
'Search for ID
SQLString = "SELECT * FROM Table WHERE [ID] = "& IDCheck
Me.RecordSource = SQLString
End If