open reports from a command button

  • Thread starter Thread starter don
  • Start date Start date
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
 
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
 
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


.
 
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


.
 
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


.
.
 
Back
Top