Optional reports

L

Leslie Isaacs

Hello All

I have a button on a form that is used to preview a particular report.
I would like to give the user the ability to select one of three reports,
after clicking the button.
I have in mind something like:


Private Sub Command71_Click()
On Error GoTo Err_Command71_Click
Dim stDocName As String
If [Print which letter - enter 1 ,2 or 3] =1 Then
stDocName = "rpt_letter_1"
DoCmd.OpenReport stDocName, acPreview
Else
If [Print which letter - enter 1 ,2 or 3] =2 Then
stDocName = "rpt_letter_2"
DoCmd.OpenReport stDocName, acPreview
Else
stDocName = "rpt_letter_3"
DoCmd.OpenReport stDocName, acPreview
End If
End If
Exit_Command71_Click:
Exit Sub
Err_Command71_Click:
MsgBox Err.Description
Resume Exit_Command71_Click
End Sub

.... but I find that I cannot have the user enter the parameter value [Print
which letter - enter 1 ,2 or 3] like I would in a query.

So how do I do it?

Hope someone can help.

Many thanks
Leslie Isaacs
 
S

SteveS

Leslie said:
Hello All

I have a button on a form that is used to preview a particular report.
I would like to give the user the ability to select one of three reports,
after clicking the button.
I have in mind something like:


Private Sub Command71_Click()
On Error GoTo Err_Command71_Click
Dim stDocName As String
If [Print which letter - enter 1 ,2 or 3] =1 Then
stDocName = "rpt_letter_1"
DoCmd.OpenReport stDocName, acPreview
Else
If [Print which letter - enter 1 ,2 or 3] =2 Then
stDocName = "rpt_letter_2"
DoCmd.OpenReport stDocName, acPreview
Else
stDocName = "rpt_letter_3"
DoCmd.OpenReport stDocName, acPreview
End If
End If
Exit_Command71_Click:
Exit Sub
Err_Command71_Click:
MsgBox Err.Description
Resume Exit_Command71_Click
End Sub

... but I find that I cannot have the user enter the parameter value [Print
which letter - enter 1 ,2 or 3] like I would in a query.

So how do I do it?

Hope someone can help.

Many thanks
Leslie Isaacs

One way would be to add an option group on the form. Then the letter could be
selected before the button is pushed.

To use your method, you need the Inputbox() function. I modified you code, but
it is untested. (watch for line wrap)

'**** begin AIR code ******
Private Sub Command71_Click()
On Error GoTo Err_Command71_Click
Dim stDocName As String
Dim Response As Integer

Response = InputBox("Print which letter? (enter 1 ,2 or 3)", "Select
Letter to Print")

Select Case Response
Case 1
stDocName = "rpt_letter_1"
Case 2
stDocName = "rpt_letter_2"
Case 3
stDocName = "rpt_letter_3"
Case Else
MsgBox "Print canceled - you didn't select a letter"
Exit Sub
End Select



DoCmd.OpenReport stDocName, acPreview
Exit_Command71_Click:
Exit Sub
Err_Command71_Click:
MsgBox Err.Description
Resume Exit_Command71_Click
End Sub
'**** end code *****
 

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

Similar Threads


Top