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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command button to open report AND add text to unbound field 1

Status
Not open for further replies.

JoeCruse

Technical User
Oct 10, 2003
41
US
Hi to all!

I'm trying to "jazz" up my lab application. I have a set of six similar reports that I'd like to take to just one report. It's a report of daily chemistries that my analysts generate each night, using a command button for each of the 6 reports. The buttons all pull up the same dialog form that allows them to select a file name and the dates. I use 6 different reports with the same format for a preliminary sample and final sample report from 3 operations-6 reports of the same format, total. I'd like to have one report in my application. I'd like to keep 6 different buttons, and have each button not only pull the one report, but also put text into 2 unbound text boxes ( one is fce, and one is sampletype).
When the report is activated, it pulls up the dialog box for the parameters, through the "On Open" property of the report.

Here is what I have now, in the code behind the first button to attempt this:

start***
Private Sub Ctl15FINAL_Click()
On Error GoTo Err_Ctl15FINAL_Click

Dim stDocName As String

stDocName = "DAILY FURNACE REPORT"
DoCmd.OpenReport stDocName, acPreview, , Me!fce = "15"



Exit_Ctl15FINAL_Click:
Exit Sub

Err_Ctl15FINAL_Click:
MsgBox Err.Description
Resume Exit_Ctl15FINAL_Click
End Sub
end***

I've tried getting the unbound "fce" report control to be 15 a couple of other different ways, based on what I've found here, but no luck. Looking through archives here and in my Access book has yielded nothing, so...
do any of you folks have an idea?

I know I could simply make the dialog form with the necessary input equipment on it, but I'd like to make this as close to a one-click operation as I can.

Thanks in advance for any information.

Regards,

Joe
 
Could you add a couple text boxes to your form and then stick values into the text boxes. Your report could then use text boxes with control sources like:
=Forms!frmYourFrom!txtfce

Your code might include

Private Sub Ctl15FINAL_Click()
On Error GoTo Err_Ctl15FINAL_Click

Dim stDocName As String
Me.txtfce = 15
Me.txtSampleType = "Urine"
stDocName = "DAILY FURNACE REPORT"
DoCmd.OpenReport stDocName, acPreview, , Me!fce = "15"
Exit_Ctl15FINAL_Click:
Exit Sub

Err_Ctl15FINAL_Click:
MsgBox Err.Description
Resume Exit_Ctl15FINAL_Click
End Sub


Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Duane,

Thank you for replying.

I was just about to make a long post about how your suggestion was not working for me after a few hours of work, when the answer smacked me in the head.

I had tried your suggestion prior to posting, but could not get it to work at all. After your reply, I tried more, but got zip for results. I either got an error that the application could not find the text boxes referred to in the code, or worse.

While I was typing in another question for you, it hit me that the text boxes needed to be on my main swithboard where the 6 command buttons are, NOT on the pop-up dialog form for the report!

DOOOOOHHHHHHHHHHH!!!!!!!!!!!!!!

It works like a charm now. Thanks very much for your help. Have a star on me!

Joe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top