Creating a list box that opens the selected report

K

K

Good day,

I am able to create the list box with the reports in my Dbase however I am
unable to achieve the end result I would like which is on double click it
opens the report selected in the list box. Could someone please help me with
this. I am trying to achieve the same thing that is in a templete on
microsoft called orders Dbase. (View Reports).

Thanks
 
F

fredg

Good day,

I am able to create the list box with the reports in my Dbase however I am
unable to achieve the end result I would like which is on double click it
opens the report selected in the list box. Could someone please help me with
this. I am trying to achieve the same thing that is in a templete on
microsoft called orders Dbase. (View Reports).

Thanks

The list box column that shows the report name is the bound column?
Code the Double-click event:

DoCmd.OpenReport Me!ListBoxName, acViewPreview
 
K

K

I now get an error message if I cancel opening the report becasue I have
parameters. What else should I add to the code to prevent this?

Thanks
 
F

fredg

I now get an error message if I cancel opening the report becasue I have
parameters. What else should I add to the code to prevent this?

Thanks

You have to trap for Error 2501 in the Double-click event that started
the whole process:

On Error GoTo Err_Handler

DoCmd.OpenReport Me!ListBoxName, acViewPreview

Exit_This_Sub:
Exit Sub
Err_Handler:
If Err = 2501 Then
Else
MsgBox "Error #: " & Err.Number & " " & Err.Description
End If
Resume Exit_This_Sub
End Sub
 
K

K

Hi Fred,

Thanks for taking the time to help me with this but I still get the 22501
run time error after if I cancel the event. The code is below. Is there
something I am missing? thanks K.

Private Sub List15_DblClick(Cancel As Integer)

DoCmd.OpenReport Me!List15, acViewPreview

On Error GoTo Err_Handler
Exit_This_Sub:
Exit Sub
Err_Handler:
If Err = 2501 Then
Else
MsgBox "Error #: " & Err.Number & " " & Err.Description
End If
Resume Exit_This_Sub
End Sub
 

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