Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

if value is 1,then run rpt A, ..., ...,

Status
Not open for further replies.
Dec 5, 2005
40
US
I want to be able to have the report that's being run be dependent on a value in a record.

i.e. if reportvalue = 1, then run reporta
if reportvalue = 2, then run reportb
if reportvalue = 3, then run reportc

I know as much as that it is a nested if then statement... can anyone help.

Thanks,
Nick
 
The code for opening a report is

Code:
DoCmd.OpenReport "Report Name", acViewPreview

Do you have a form that shows each record? How is this code run? With a command button?

Need more information to help.
 
How are ya nickrugado . . .

Here's an example:
Code:
[blue]   Dim [purple][b]rptName[/b][/purple] As String
   
   [purple][b]rptName[/b][/purple] = Choose(Me!ReportValue, "reportaName", _
                                    "reportbName", _
                                    "reportcName")
   DoCmd.OpenReport [purple][b]rptName[/b][/purple], acViewPreview[/blue]

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Doing well, Thanks for your answer... I have another question about the syntax and the meaning...
How does it know that 1 is to run A and 2 is to run B .... ? Is it the order in which they are listed above?
 
nickrugado . . .

[ol][li]From the database window hit [blue]Ctrl + G[/blue].[/li]
[li]In the immediate window type [blue]Choose[/blue]. Put the cursor on the word and hit [blue]F1[/blue][/li][/ol]
Its called [blue]context sensitive help[/blue] and is Microsofts best for calling up info. Another example:

Put the cursor or a [blue]property[/blue] or [blue]event[/blue] line. Hit [blue]F1[/blue] and read all about it! [thumbsup2]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
nickrugado . . .

Put the cursor or a property or event line. Hit F1 and read all about it!

should be

Put the cursor [blue]on[/blue] a property or event line. Hit F1 and read all about it!

Sorry about the mess [surprise]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top