Similar case here...
Hi Bob, hi habbabub
I have a very similar case here. I have a button in a form (let's call it frm_SEARCH_FORM) that takes parameters from the form, passes them to a query (qry_SEARCH), so that a report (rpt_SEARCH_RESULTS) opens accordingly. Currently the report opens even if there aren't any data to show.
Instead of having a message box though, I would like to open a new form to pass the message. So, when the user will click on the "SEARCH" button of the frm_SEARCH_FORM, in case there are no results, then:
1. frm_SEARCH_FORM will close completely
2. the rpt_SEARCH_RESULTS doesn't open at all
3. a new form opens (let's name it frm_NO_RESULTS) saying that no records satisfy the criteria (and other blablabla included in a simple text label), and include a button that would allow the user to either re-open the search form, or return to the main menu, or even exit the DB completely.
I created a macro that opens the NO_RESULTS form, named it macro_NO_RESULTS and assigned it to the NoData event of my report. All works fine, except that the rpt_SEARCH_RESULTS still opens (and actually it opens in front of frm_NO_RESULTS, but I can fix this), even when there's no data in it to be shown.
So what sould I do for this? Should I change this...
Private Sub Report_NoData(Cancel As Integer)
MsgBox ("asd")
Cancel=True
End Sub
...to this?
Private Sub Report_NoData(Cancel As Integer)
frm_NO_RESULTS
Cancel=True
End Sub
Well, I'm sure that's a wrong syntax (my VBA knowledge is sub-zero)
What exaclty should I type and where?
Thanks in advance,
Alexander