Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If Record Source is Null then what?? 1

Status
Not open for further replies.

Callreluctance

Technical User
Jan 3, 2003
25
US
I set up a query to do a basic sort. It uses "or" statements for 3 fields: LastName, Company, ProjDev. I then use a button to instigate the query and search, and set my recordsource=ContactsQuery2 (the query). Works great when there is data in the Query. When the query cannot find matching data, my form goes crazy and won't display anything, even blank fields. Is there anyway to check if the Recordset or RecordSource is Null and using an if statement change the recordsource back to the usual table (Contacts). I will input a msgbox saying Data Not Found. HELP!
 
You could check the RecordCount property of the form and if it's 0, change you RecordSource.

If (Me.Recordset.RecordCount = 0) then blah blah blah

This will give you an answer of at least 1, if you want to know exactly how many, then do this:

Me.Recordset.MoveLast
msgbox Me.Recordset.RecordCount
Me.Recordset.MoveFirst
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top