DanGriffin
Programmer
I have an application that collects employee application info. When a new record is saved, it prints an envelope with the applicant's name and address and a code based on certain criterion.
The problem is, when the report preview (of the envelope) comes up and the user presses PRINT icon, a SCREEN PRINT of the underlying form is printed instead of the envelope (report) that is currently displayed on the screen!?!?!
What's going on?
This is the code that calls the report:
If MsgBox("Do you wish to print an envelope for this person?", vbQuestion + vbYesNo, "Notification Envelope" = vbYes Then
Me!TestLetter = Date
Me.Refresh
DoCmd.OpenReport "Envelope", acPreview, , , , sArgs
End If
...and this is the code behind the reports:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim dbs As Database, rst As Recordset
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("SELECT * FROM [" & sYearFile & "] WHERE [" & sYearFile & "].SSnum = '" & Forms![Applicant Form]!SSnum & "';"
Me!Name = rst!Name
Me!Address = rst!Address
Me!City = rst!City & ", " & rst!State & " " & rst!Zip
Me!PosCode = Me.OpenArgs
rst.Close
Set dbs = Nothing
End Sub
...one interesting note: If I remove the reference to the underlying form from the end of the SELECT query, the envelope prints fine(!!) [For every record of course]
Most strange. Anyone have any hint as to why? And/or what to do about it?
Thanks in advance for your time and trouble.
Dan
The problem is, when the report preview (of the envelope) comes up and the user presses PRINT icon, a SCREEN PRINT of the underlying form is printed instead of the envelope (report) that is currently displayed on the screen!?!?!
What's going on?
This is the code that calls the report:
If MsgBox("Do you wish to print an envelope for this person?", vbQuestion + vbYesNo, "Notification Envelope" = vbYes Then
Me!TestLetter = Date
Me.Refresh
DoCmd.OpenReport "Envelope", acPreview, , , , sArgs
End If
...and this is the code behind the reports:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim dbs As Database, rst As Recordset
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("SELECT * FROM [" & sYearFile & "] WHERE [" & sYearFile & "].SSnum = '" & Forms![Applicant Form]!SSnum & "';"
Me!Name = rst!Name
Me!Address = rst!Address
Me!City = rst!City & ", " & rst!State & " " & rst!Zip
Me!PosCode = Me.OpenArgs
rst.Close
Set dbs = Nothing
End Sub
...one interesting note: If I remove the reference to the underlying form from the end of the SELECT query, the envelope prints fine(!!) [For every record of course]
Most strange. Anyone have any hint as to why? And/or what to do about it?
Thanks in advance for your time and trouble.
Dan