Pass a value from dialog box to text box on report

  • Thread starter Thread starter Gina
  • Start date Start date
G

Gina

Hello All!

I have a dialog box from which I print reports. I want to
pass values entered on the dialog form to my reports. It
works when I print directly from the dialog form, but when
I go to print preview first I lose my values.

Here's a portion of my code:
Visible=False
If (ReptToPrint = 2) Then
DoCmd.OpenReport "rptEventsByEE", acPreview, "", Eval("IIf
([Forms]![frmPrintReports]![cboEvents] Is Null,""[Date]
Between Forms![frmPrintReports]![txtBegDate] and Forms!
[frmPrintReports]![txtEndDate]"",""[EmployeeName]= Forms!
[frmPrintReports]![cboEvents]and [Date]Between Forms!
[frmPrintReports]![txtBegDate] and Forms![frmPrintReports]!
[txtEndDate]"")")
End If
DoCmd.Close acForm, "frmPrintReports"

I guess the reason it doesn't work when I print preview
and then print (from the print icon) is because the print
dialog box is closed in the code. (The values show up in
print preview, but when I print the hard copy I get the
#Name? error.)

Hopefully I've made myself clear...can someone help me
modify my code (or write new code) to leave the print
dialog box open long enough for me to print a hard copy
from print preview? I'm rather new at this...I still
can't believe I can write any code at all!

Thanks so much.
 
Keep the form open until the report is closed. If you want, you can make the
form invisible.
 
Duane,

Thanks for the advice...I guess it was pretty obvious, but
as I said I'm new at this.
Thanks again!
-----Original Message-----
Keep the form open until the report is closed. If you want, you can make the
form invisible.

--
Duane Hookom
MS Access MVP


Gina said:
Hello All!

I have a dialog box from which I print reports. I want to
pass values entered on the dialog form to my reports. It
works when I print directly from the dialog form, but when
I go to print preview first I lose my values.

Here's a portion of my code:
Visible=False
If (ReptToPrint = 2) Then
DoCmd.OpenReport "rptEventsByEE", acPreview, "", Eval ("IIf
([Forms]![frmPrintReports]![cboEvents] Is Null,""[Date]
Between Forms![frmPrintReports]![txtBegDate] and Forms!
[frmPrintReports]![txtEndDate]"",""[EmployeeName]= Forms!
[frmPrintReports]![cboEvents]and [Date]Between Forms!
[frmPrintReports]![txtBegDate] and Forms! [frmPrintReports]!
[txtEndDate]"")")
End If
DoCmd.Close acForm, "frmPrintReports"

I guess the reason it doesn't work when I print preview
and then print (from the print icon) is because the print
dialog box is closed in the code. (The values show up in
print preview, but when I print the hard copy I get the
#Name? error.)

Hopefully I've made myself clear...can someone help me
modify my code (or write new code) to leave the print
dialog box open long enough for me to print a hard copy
from print preview? I'm rather new at this...I still
can't believe I can write any code at all!

Thanks so much.


.
 
Back
Top