G
Guest
I am having the worst time figuring out what I'm doing wrong. I have a form that works very well and need to print a report based on the form that is showing. I have tried the examples I've seen here and used the wizard but I can't get it to work. It always goes back to the first record no matter what form is showing. The following is the code I have to preview the report. When I test values in the report code the current form values are there but don't get used when the preview window opens
Private Sub preview_Click(
On Error GoTo Err_preview_Clic
Dim stDocName As Strin
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70 'refres
DoCmd.Minimize ' minimizes the for
stDocName = "rptWSWD
DoCmd.OpenReport stDocName, acPreview, , "rReportNoID = " & Me!fReportNoI
Exit_preview_Click
Exit Su
Err_preview_Click
MsgBox Err.Descriptio
Resume Exit_preview_Clic
End Su
This is some of the code I have in the report. Zeronull is a function I have to assign the values 1, 0 or null to unbound textbox controls based on the -1,0 values of a checkbox and text in another control. It works very well in both the form and report
I have the line " Y = ... " to test the value and it gives the value of the form that is showing. As does Wkend have the correct date of the form. But when the report opens it starts at the first record
Private Sub Report_OPEN(Cancel As Integer
Y = Forms![frmWSWD]!fReportNoI
WKend = Forms![frmWSWD]!tWkEndin
For N = 0 To
STR = "=ZeroNull([fWD" & N & "],[tCond" & N & "])
Set CTRL = Controls("uWD" & N
CTRL.ControlSource = STR
Next
Maybe someone can spot what I'm doing wrong or let me know what else I have to add
Thanks
Private Sub preview_Click(
On Error GoTo Err_preview_Clic
Dim stDocName As Strin
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70 'refres
DoCmd.Minimize ' minimizes the for
stDocName = "rptWSWD
DoCmd.OpenReport stDocName, acPreview, , "rReportNoID = " & Me!fReportNoI
Exit_preview_Click
Exit Su
Err_preview_Click
MsgBox Err.Descriptio
Resume Exit_preview_Clic
End Su
This is some of the code I have in the report. Zeronull is a function I have to assign the values 1, 0 or null to unbound textbox controls based on the -1,0 values of a checkbox and text in another control. It works very well in both the form and report
I have the line " Y = ... " to test the value and it gives the value of the form that is showing. As does Wkend have the correct date of the form. But when the report opens it starts at the first record
Private Sub Report_OPEN(Cancel As Integer
Y = Forms![frmWSWD]!fReportNoI
WKend = Forms![frmWSWD]!tWkEndin
For N = 0 To
STR = "=ZeroNull([fWD" & N & "],[tCond" & N & "])
Set CTRL = Controls("uWD" & N
CTRL.ControlSource = STR
Next
Maybe someone can spot what I'm doing wrong or let me know what else I have to add
Thanks