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

How Can I Identify a Null Recordset in a form

Status
Not open for further replies.

AnotherGraham

Programmer
Jan 12, 2003
11
0
0
US
I have set up a form to retrieve a subset of records from a query based on data entered. I would like to be able to identify if no records were retrieved as this will affect the next actions. As this is only one aspect of multiple form interactions I would prefer to do this from within the form eg with properties or a DoCmd statement, rather than using an ADO recordset. All of my attempts such as If IsNull(Me) etc have failed. I would appreciate any suggestions.
Thanks in advance
Graham
 
HI

Have you tried:

If Me.Recordsetclone.recordcount < 1 Then
...etc
end if

or

If Me.Recordcount < 1 Then
...etc
End If

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
The following code will return the number of records in a given query:

=DCount(&quot;[FIELD X]&quot;,&quot;[QUERY X]&quot;)

The query does NOT have be related to the object with the code. For example, you could put this code in a form, and the form's data source could be something other than Query X, and the code would work.

I am assuming that:

1)Query X and its data source will always exist. For example, lets say that Query X's data source is Table X. My solution would work if Table X had zero records (the Dcount would return 0). However, it would NOT work Table X did not exist.

2)Field X will aways have data in it. You should do something like make Field X an autonumber field, or in the query put &quot;field x:1&quot;.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top