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

Open Form depending on query results

Status
Not open for further replies.
May 9, 2000
446
GB
Hi, i have a form that runs a query 'in the background' just wondering whether its possible to open a form if the queryr eturns any results, if the query doesn't find any records the form doesn't open. I could use a report, on no data event, but a form would be better

cheers
 
Yep, try this...

If DCount("*", "[Your Query Name]") > 0 Then
DoCmd.OpenForm "[Your Form Name]", acNormal
End If
 
Dear vanillapod,

to test whether a recordset returns results, you can check the recordcount property.

Dim daorec As DAO.Recordset

Set daorec = Application.CurrentDb.QueryDefs("abfrage1").OpenRecordset
if daorec.recordset > 0 then
'open your form
endif


regards Astrid
 
dear vanillapod,

sorry typo:

if daorec.recordcount > 0 then
'open your form
end if

regards Astrid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top