Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Command Button

Status
Not open for further replies.

EastIndian

Technical User
Mar 21, 2002
18
0
0
US
Unable to search by keyword to see if this has been answered in the past, sorry.

I have created a form where I would like to add a command button to preview a report based on some criteria entered in my form. For example, in the form, I chose a project "A" which has a primary key "1". I would then like to preview the report for project "A". Because there are several reports (Project A-Z), I do not want the report choice for my preview report command button to be "hard coded" and static. Can anyone point me in the right direction to do this?
Thank you,
Brandy
 
Try this

On Error GoTo Err_Command12_Click

Dim stDocName As String
Dim ProjChoice As String

stDocName = "IsError"
ProjChoice = InputBox("Enter Project Code", "Project Code Selection")
DoCmd.OpenReport stDocName, acPreview, , "[Project] = '" & ProjChoice & "'"

Exit_Command12_Click:
Exit Sub

Err_Command12_Click:
MsgBox Err.Description
Resume Exit_Command12_Click

End Sub
[yinyang]
 
do you have a seprate report for each project,or do you have 1 report and select diffrent data?
if you have seprate reports and your reports are the same as the project names and you select with a combobox then
docmd.openreport me.combobox
if you have a prefix to the report ie: rptprojecta then
docmd.openreport "rpt" & me.combobox
but if you just want to select diffrent data for each report
then put i a hidden column in the combobox the data that you want and this is the command
docmd.openreport "reportname",,,"primarykeyfildname=" & me.combobox.column(1)


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top