Wrong Form opening

P

ProjectUser

Here’s my dilemma:

I’ve created a form as my switchboard, which isn’t loading properly.
Instead of seeing the switchboard form when you open the database, I’m seeing
my report criteria dialog form associated. When I close this criteria dialog
form, then the switchboard form appears. The same results occur when you
also select the switchboard form – the criteria report dialog form appears
first, then the switchboard form once the report criteria dialog form is
closed.

For background purposes/details:
There are no event procedures written for this switchboard form. So, it’s
baffling to me that that when you select the switchboard form, another form
opens (report criteria form). On the switchboard form are three toggle
buttons within an option frame. Two buttons are coded to open forms, the
third button is coded to open the report criteria dialog form which has a run
report command button on it.

Here’s the code I’m using for the three toggle buttons:

Private Sub Toggle3_GotFocus() ‘this is the button that seems to be creating
issue
DoCmd.OpenForm "FORM_RPTcriteria", acNormal, , , , acDialog
End Sub

Private Sub Toggle4_GotFocus()
DoCmd.OpenForm "FORM_A", acNormal, , , , acDialog
End Sub

Private Sub Toggle5_GotFocus()
DoCmd.OpenForm "FORM_B", acNormal, , , , acDialog
End Sub

I’ve also tried coding with a OpenReport method, resulting in an error.
Here’s what the code looks like:

DoCmd.OpenReport "RPT_WklyStatus", acViewReport, , , acWindowNormal

The report is coded to open this criteria dialog form before running the
report. So what should happen is that when you open the report, the dialog
form opens first.

I hope this wasn’t too confusing to understand. Can anyone please help?
Thanks,
 
P

Pat Hartman \(MVP\)

Based on your code, it doesn't appear that the toggle buttons are actually
part of the option group. In that case you would have only a single event
and in that event you would check the frame value to determine which button
was depressed. It seems that your buttons are just sitting on top of the
control but not actually part of it. To properly create an option group,
start with the option group control. The wizard will walk you through
creating toggle buttons, radio buttons, or check boxes along with their
associated values. Then your code goes in the click event of the FRAME for
the option group. No code goes in events of the individual choices.

With what you have now, I would guess that the Toggle3 button has the focus
when the form opens and that is why your code is opening the criteria form.
Since it opens in dialog mode, it opens in front of the "switchboard" form.

To solve your immediate problem, move the code for ALL buttons from the
GotFocus event to the Click event or recreate the option group properly.
 
F

FedBrad

Perhaps too basic, but... have you checked the 'Default Value' property of
the Option Group object itself? (i.e., when the form is opened, is the
toggle associated with opening the dialog form already checked?)
 
P

ProjectUser

This was a great help! Thanks,

I'm now encountering another issue. Here's the code that I set for the frame:

Private Sub StartupFrame_AfterUpdate()
Select Case Me.StartupFrame.Value
Case 1
Me.OptionReport.Visible = True
DoCmd.OpenForm "FORM_RPTcriteria", acNormal, , , , acDialog
Case 2
Me.OptionSchedule.Visible = True
DoCmd.OpenForm "SCHEDULE", acNormal, , , , acDialog
Case 3
Me.OptionResource.Visible = True
DoCmd.OpenForm "RESOURCE", acNormal, , , , acDialog
End Select

End Sub

The issue is with Case 1. The Report Criteria Form appears when the option
button is selected. However, in this Criteria Form is a run report button
(button has code written). After selecting the run report command button,
the report doesn't appear.

Do I need to add additional code in Case 1 to make this work properly? If
so, what please.

Thanks!
 
F

FedBrad

Sounds as though the culprit may now be in the code behind your run report
button. Does the code reference the correct report (spelled correctly,
etc.), and/or are there other references (perhaps within the underlying
query) that are incorrect?
 
P

Pat Hartman \(MVP\)

In the OpenReport method you have the option of how you want to open the
report. Sounds like you are opening it in preview mode. That opens the
report and leaves it open until the user closes it. If you want to just
print the report directly without previewing it, change the mode to normal.
 

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