open reports from a command button

D

don

i have a form to input data. is there a way to have a
command button to open up the existing reports for the
user to pick from. i have used the docmd.runcommand
accmdopenreport but it dosnt work i get the error command
isnt available. any suggestions?


thanks
 
A

Allen Browne

Place a combo box on your form, and give it these properties:
Name: cboReport
RowSource: SELECT [Name] FROM MsysObjects
WHERE ([Name] Not Like "~*") AND ([Type] = -32764))
ORDER BY [Name];

In the Click event procedure of your command button:

Private Sub cmdPrint_Click()
If IsNull(Me.cboReport) Then
Msgbox "Select a report"
Else
DoCmd.OpenReport Me.cboReport, acViewPreview
End If
End Sub
 
D

don

i placed the statement in the rowsorce and all i get is
the statement visible in the cboReport box. i do not get
the list of reports to choose from.

thanks

-----Original Message-----
Place a combo box on your form, and give it these properties:
Name: cboReport
RowSource: SELECT [Name] FROM MsysObjects
WHERE ([Name] Not Like "~*") AND ([Type] = -32764))
ORDER BY [Name];

In the Click event procedure of your command button:

Private Sub cmdPrint_Click()
If IsNull(Me.cboReport) Then
Msgbox "Select a report"
Else
DoCmd.OpenReport Me.cboReport, acViewPreview
End If
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

i have a form to input data. is there a way to have a
command button to open up the existing reports for the
user to pick from. i have used the docmd.runcommand
accmdopenreport but it dosnt work i get the error command
isnt available. any suggestions?


thanks


.
 
A

Allen Browne

Make sure the RowSourceType property of the combo is set to
Table/Query

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

don said:
i placed the statement in the rowsorce and all i get is
the statement visible in the cboReport box. i do not get
the list of reports to choose from.

thanks

-----Original Message-----
Place a combo box on your form, and give it these properties:
Name: cboReport
RowSource: SELECT [Name] FROM MsysObjects
WHERE ([Name] Not Like "~*") AND ([Type] = -32764))
ORDER BY [Name];

In the Click event procedure of your command button:

Private Sub cmdPrint_Click()
If IsNull(Me.cboReport) Then
Msgbox "Select a report"
Else
DoCmd.OpenReport Me.cboReport, acViewPreview
End If
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

i have a form to input data. is there a way to have a
command button to open up the existing reports for the
user to pick from. i have used the docmd.runcommand
accmdopenreport but it dosnt work i get the error command
isnt available. any suggestions?


thanks


.
 
G

Guest

there was one to many parantheses in the statement
i am now seeing the list of reports in the cboReport but
it will not let the report be higlited for the command
button to work

thanks
-----Original Message-----
i placed the statement in the rowsorce and all i get is
the statement visible in the cboReport box. i do not get
the list of reports to choose from.

thanks

-----Original Message-----
Place a combo box on your form, and give it these properties:
Name: cboReport
RowSource: SELECT [Name] FROM MsysObjects
WHERE ([Name] Not Like "~*") AND ([Type] = -32764))
ORDER BY [Name];

In the Click event procedure of your command button:

Private Sub cmdPrint_Click()
If IsNull(Me.cboReport) Then
Msgbox "Select a report"
Else
DoCmd.OpenReport Me.cboReport, acViewPreview
End If
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

i have a form to input data. is there a way to have a
command button to open up the existing reports for the
user to pick from. i have used the docmd.runcommand
accmdopenreport but it dosnt work i get the error command
isnt available. any suggestions?


thanks


.
.
 

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