form coding question

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
 
D

Dan Artuso

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
 
S

Squirrel

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
 

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