Smart List Box

K

Kirk P.

I've got a multi-select list box that allows me to preview selected reports.
Works fine, except certain reports (index # 3 and 4) require criteria from
frmTranDate in order to run. Is there a way to modify this code so when
index number's 3 or 4 are selected, the Tran Date form pops up?

Private Sub cmdOK_Click()
On Error GoTo Err_cmdOK_Click

Dim varPosition

For Each varPosition In Me![lstReports].ItemsSelected
DoCmd.OpenReport Me.lstReports.ItemData(varPosition), acViewPreview
Next

Exit_cmdOK_Click:
Exit Sub

Err_cmdOK_Click:
If Err.Number = 2501 Then
'Ignore the error
Resume Exit_cmdOK_Click
Else
MsgBox "Error: " & Err.Number & " " & Err.Description, 16, "Report
Print"
Resume Exit_cmdOK_Click
End If

End Sub
 
F

fredg

I've got a multi-select list box that allows me to preview selected reports.
Works fine, except certain reports (index # 3 and 4) require criteria from
frmTranDate in order to run. Is there a way to modify this code so when
index number's 3 or 4 are selected, the Tran Date form pops up?

Private Sub cmdOK_Click()
On Error GoTo Err_cmdOK_Click

Dim varPosition

For Each varPosition In Me![lstReports].ItemsSelected
DoCmd.OpenReport Me.lstReports.ItemData(varPosition), acViewPreview
Next

Exit_cmdOK_Click:
Exit Sub

Err_cmdOK_Click:
If Err.Number = 2501 Then
'Ignore the error
Resume Exit_cmdOK_Click
Else
MsgBox "Error: " & Err.Number & " " & Err.Description, 16, "Report
Print"
Resume Exit_cmdOK_Click
End If

End Sub

That's not the way to do this.

Code those 2 Report's Open Event:

DoCmd.OpenForm "Tran Date", , , , , acDialog

Code the Report's Close event:

DoCmd.Close acForm, "Tran Date"

Add a command button to the form:
Me.Visible = False

Then simply open those reports the same as you do the others.
When the report opens, it will open the form. Processing will stop
until the parameters have been entered and the form command button
clicked.
Then the report will display.
When you close the report, it will also close the form.
 

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