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!

Custom Dialog Box that enters text on a report 1

Status
Not open for further replies.

WallT

Vendor
Aug 13, 2002
247
US
I have a report that is a Work Order. Everytime the work order is printed I would like to add some "Special Instructions" to it. However, I don't want the instructions being saved in the database as a field in a table, I just want them to print on the Work Order. The same work order may get printed several times for different reasons, and the "Special Instructions" will be different each time and there is no reason to save them.

I've tried using an unbound "Text Box" where I want the instructions, and then a standard Pop Up Dialog Box allows me to type in it, but that dialog box is really to small to type a lot of Instructions in.

Can somebody point me in a direction of a possible custom dialog that I can make as a form that will Pop up and let me type these instructions in? Thank you.
 
How are ya WallT . . .
WallT said:
[blue]Can somebody point me in a direction of a possible custom dialog . . .[/blue]
Simple really. All you need is a form with a [blue]single unbound textbox[/blue] (sized to your needs) and a [blue]command button[/blue] to open the report. The forms [blue]Popup[/blue] property would be set to yes.

Next in your button code you'd have:
Code:
[blue]   DoCmd.OpenReport "[purple][b]ReportName[/b][/purple]", acViewPreview[/blue]

Three things have to be done in the report:
[ol][li][blue]Hide the custom form![/blue] Since its a popup the report will appear behind it. Also we still need the form open as were gonna snatch the instructions right off the form.[/li]
[li]Transfer the instructions from the form to the reports ubbound textbox.[/li]
[li]Close or make visible the custom form.[/li][/ol]
So in the [blue]On Open[/blue] event of the report:
Code:
[blue]   Forms![[purple][b]CustomFormName[/b][/purple]].Visible = False[/blue]
Next in the [blue]On Print[/blue] event of the reports [blue]section[/blue] where you placed the unbound textbox:
Code:
[blue]   Me![purple][b]ReportTextboxName[/b][/purple] = Forms![[purple][b]CustomFormName[/b][/purple]]![[purple][b]InstructionTextboxName[/b][/purple]][/blue]
Finally in the reports [blue]On Close[/blue] (use one of the following lines):
Code:
[blue]   docmd.Close acForm,"[purple][b]CustomFormName[/b][/purple]",acSaveNo
or
   Forms![[purple][b]CustomFormName[/b][/purple]].Visible = True[/blue]
[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Awesome. I was trying to add the text and close the form all in one shot, but that wasn't working. This is working great. The only thing different I did was put the code in the sections "OnFormat" Event instead of the "OnPrint" Event. Works great, thank you.
 
BTW . . . if you don't already know, while your editing your instructions you can use [blue]Ctrl + Enter[/blue] to start new lines! . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top