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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Queries that don't return any records

Status
Not open for further replies.

sbhTexas

Technical User
Oct 25, 2000
1
US
I have two forms, one that will always have the current date, the other will have records based on a date. There can be two or three records for a date, but not all dates will have matching records. I joined them with a query--join field date. (sometimes the query will return records, sometimes it will be blank)
THere is also a form based on this query.
I want to use code to open the form only is there is a record for the current day.
If there is no data, I want to go ahead and open another form.
Help!
 
There are several possabilities here. One is to open the query as a recordset before opening the form. Check the Record count property of the recordset. If it is zero, then do your second action, else open the form. You should generally do at least some type of move in the recordset before checking the record count, or check it several times (programatically), as Some versions of Ms. Access MAY report a zero record count IMMEDIATLY after opening a record set.

Another possability is simply to do .MoveNext on the record set, and check for the "past EOF" error. If the recordset has no records, the move will create an error.

MichaelRed
mred@duvallgroup.com
There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top