cancel open form on-click if no query data

  • Thread starter Thread starter MES via AccessMonster.com
  • Start date Start date
M

MES via AccessMonster.com

I have a form that has a command button that opens another form on click.
This other form has a combo box from which I select an option for further
view. This combo box's row source is a select query. If my select query has
no data, in the on-click event of the first form, I would like to display a
message box telling the user to do something else, rather than opening the
second form.

Is there any way to do this? Any help would be greatly appreciated. Thanks
in advance.
 
Check to see what the select query will return before opening the form:

Dim rst As Recordset

Set rst = CurrentDb.OpenRecordset("MySelectQueryName")
If rst.RecordCount <= 0 Then
MsgBox "No Records Found"
End If
rst.Close
set rst = Nothing
DoCmd.OpenForm....
 

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

Back
Top