cancel open form on-click if no query data

  • Thread starter MES via AccessMonster.com
  • 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.
 
K

Klatuu

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....
 
Top