Report = No Data >>> previous form maximizes

T

Tom

Hello Experts,

I have a simple problem that I can't figure out... let me desribe the
problem in bullet format:

- I have a "login form" that contains a listbox. When selecting a value
from the listbox, it opens the specified report
- The size of the login form is NOT maximized (I believe it's called
"Restore" mode... the button between Minimize or Maximize form)
- Most of my reports have data... however, some of them don't have data yet
- When clicking on a report that HAS data, everything works great. Report
opens (in maximized view)... I close report and I'm back to the login form
(in Restore mode)
- However, when clicking on a report that has NO data, the "On No Data"
function kicks in and throws the dialog box... which is good. Now, when
clicking OK on the dialog box (which closes the report in the background I
guess), my login form is now maximized. I don't want that! I want the
login form to stay the same size (Restore mode) regardless of having or not
having data in the report.

Below is the listbox function that is part of my login form. Thus far,
I've used the approach #2 " (see comment >> '2. Below is current approach
(for opening report) <<).

However, I have browsed in Newsgroups and noticed someone's recommendation.
See comment #1 (>> '1. Below is NEW approach (for opening report) <<).

I believe that approach checks first if the report has any data associated
with it... if no, no further action is taken. I think that would solve my
problem (not sure though).

At this time, I get the following error: "Compile error. Sub or Function
not defined".

Line >> Set rs = CreateRecordset([Query1]) << is highlighted when clicking
Debug.

What is missing? Is this the best approach to solve the problem of "not
maximizing form" when report has no data?

Thanks,
EEE




================================

Private Sub ListBoxReports_AfterUpdate()

Dim rs As String

'1. Below is NEW approach (for opening report)
If Me.ListBoxReports = "Report #1" Then

Set rs = CreateRecordset([Query1])
If rs.EOF And rs.BOF Then
MsgBox "Sorry, no data available!"
Else
'If data available, open report
DoCmd.OpenReport "Report1", acViewPreview
End If



'2. Below is current approach (for opening report)
ElseIf Me.ListBoxReports = "Report #2" Then
On Error Resume Next
DoCmd.OpenReport "Report2", acViewPreview
DoCmd.Maximize
DoCmd.RunCommand acCmdZoom100
End If

End Sub
 

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