If Statement

J

Jeff

I need code to accomplish the following:

1. Run "Alpha" query
2. If "Alpha" query has any results, open "Beta" form,
otherwise show message box stating "No results".

Any help will be greatly appreciated. Thanks.
 
C

Cheryl Fischer

If "Alpha" query is the RecordSource for "Beta" form, you can put the
following code in the OnOpen event of "Beta" form:

If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "There are no results to review."
Cancel = True
End If
 
J

JimH

-----Original Message-----
I need code to accomplish the following:

1. Run "Alpha" query
2. If "Alpha" query has any results, open "Beta" form,
otherwise show message box stating "No results".

Any help will be greatly appreciated. Thanks.
.
easy way is make alpha query recordsource for beta form
can use varying criteria if you want to use beta for other
queries
docmd.hourglass true
docmd.openform "Beta", , , , , acHidden
if conditions then
me.recordsource=alpha
end if
if Me.RecordsetClone.RecordCount = 0 then
msgbox " No Records Found",vbexclamation,"No results"
docmd.close acform,"Beta"
else
me.visible=true
docmd.hourglass false
end if
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top