form coding question

  • Thread starter Thread starter Bri
  • Start date Start date
B

Bri

I'm fairly new at programming and could use some help. I have a form
(frmPrintSwitchboard) that contains 8 buttons (cmdPrintRptNovice, cmd
PrintRptTyro, etc). When any of these buttons is clicked, I want a second
form (frmSelectSession) to pop up that contains a combobox (cmbSession).
This lists sessions Fall, Winter Spring, etc. The user, with two clicks,
could print a report for, say, Novice division - Fall session.

Here's the question. I want to use only one frmSelectSession. (Don't
laugh, but I currently have 8, one dedicated to each report button.) How do
I do this? Somehow I need to pass the info about which report was selected
through this form so I can print the right report.

Thank you
Bri
 
Hi,
You can pass info to the form through the OpenArgs argument of OpenForm.

So, if you clicked on your cmdPrintRptNovice button,
you could do something like this:

DoCmd.OpenForm "frmSelectSession",,,,,,"novice"

Now, in frmSelectSession, you can simply check OpenArgs:

Select Case Me.OpenArgs
Case "novice"
DoCmd.OpenReport "rptNovice" 'or whatever it's called
Case "tyro"
DoCmd.OpenReport "rptTyro" 'or whatever it's called
End Select
 
Hi Bri,

Here's a suggestion which you might try if you were willing to do this via
one form instead of
opening a second form to choose the semester.

Add a combobox to frmPrintSwitchboard - call it cboSessions.
Look at the properties dialog for the combobox.
Set the Row Source Type to: Value List
Set the Row Source to: Fall;Winter;Spring;Summer
Set the Default Value to: "Fall"

Then for each report:
Look at the properties dialog and
Set Filter On = Yes
Set Filter = [Session] = Forms![frmPrintSwitchboard]![cboSessions]

Perhaps [Session] isn't the fieldname in the report but I hope you get the
idea. You'll use your
frmPrintSwitchboard with its eight report buttons and one combobox to select
the session.

HTH -Linda
 
Back
Top