S
Samantha
I'm querying using code but need the right code to test whether there were
any records found as a result. Anyone has any pointers? The query is based
on a textbox txtPartNumber.
here's my code:
Dim d As Database
Dim rsClass As Recordset
Dim strSQL As String
Dim strInput As String
Dim strClass As String
Set d = CurrentDb
strInput = Me!txtPartNumber
strSQL = "SELECT dbo_PartMaster.PartNumber, dbo_PartMaster.ProductClass FROM
dbo_PartMaster WHERE"
strSQL = strSQL & "[dbo_PartMaster.PartNumber] = '" & strInput & "'"
Set rsClass = d.OpenRecordset(strSQL, DB_OPEN_DYNASET)
strClass = rsClass("ProductClass")
Me!cboClass.Value = strClass
rsClass.Close
d.Close
The error is at the line: strClass=rsClass("ProductClass") when there is no
record found. What's the code to find out when there is no record found?
I tried the following, but it doesn't work:
if isnull( rsClass("ProductClass") ) then
'do nothing
end if
Please help!!!! thank you fo so much.
Samantha
any records found as a result. Anyone has any pointers? The query is based
on a textbox txtPartNumber.
here's my code:
Dim d As Database
Dim rsClass As Recordset
Dim strSQL As String
Dim strInput As String
Dim strClass As String
Set d = CurrentDb
strInput = Me!txtPartNumber
strSQL = "SELECT dbo_PartMaster.PartNumber, dbo_PartMaster.ProductClass FROM
dbo_PartMaster WHERE"
strSQL = strSQL & "[dbo_PartMaster.PartNumber] = '" & strInput & "'"
Set rsClass = d.OpenRecordset(strSQL, DB_OPEN_DYNASET)
strClass = rsClass("ProductClass")
Me!cboClass.Value = strClass
rsClass.Close
d.Close
The error is at the line: strClass=rsClass("ProductClass") when there is no
record found. What's the code to find out when there is no record found?
I tried the following, but it doesn't work:
if isnull( rsClass("ProductClass") ) then
'do nothing
end if
Please help!!!! thank you fo so much.
Samantha