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

recordcount query 1

Status
Not open for further replies.

matrixindicator

IS-IT--Management
Joined
Sep 6, 2007
Messages
418
Location
BE
hey,

In my form the user make some selections as year and other criteria to generate a query, this works fine.
somethimes the query don't get a result, eg. the year chosen in combination with other criteria does not produce a result. At this moment he shows a empty query. I like to verify is there is no record(s) available for the query he should mention a message on the screen like 'no data available".

Is a recordcount on the query the best way to do this, what is the best way to dedect it, if there is a query result, yes or no ?

matrixindicator
 
Hello,

Code:
Dim myDatabase As DAO.Database
Dim QueryResults As Recordset

Set myDatabase = CurrentDb

Set QueryResults = myDatabase.OpenRecordset("QryP1", dbOpenDynaset)

QueryResults.MoveLast
Resultcount = QueryResults.RecordCount

If Resultcount = 0 Then
    Me!txtNoQUERY.Visible = True
Else
    DoCmd.OpenQuery "QryP1", acViewNormal
End If

QueryResults.Close

End Sub

When I try to run this, the answer is "to few parameters". Is something missing or can I do this not in this way ?
 
You may try this:
Code:
If DCount("*", "QryP1") = 0 Then
    Me!txtNoQUERY.Visible = True
Else
    DoCmd.OpenQuery "QryP1", acViewNormal
End If

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top