Question : Open report hidden for snapshot

Hi all
I have a chunk of code I use to attach a report as a snapshot to an email. Ive discovered I have format conditions which kick in  when the Report is opened. When the report is outputted to my email these formats are not activated. I thought a work around would be to open the report hidden and then have the snapshot created. however that dosent seem to work reliabily and the report wants to print to the default printer.
The : DoCmd.OpenReport "Control2", , , , acHidden
and
DoCmd.Close acReport, "Control2"
are my additions, prior to this all worked except I wasnt getting the special formatting for some of the records being output

Paul

Sorry about the points seems I have none
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
Function HEDLSnapshot(strReport As String, strEMail As String, strSubj As String, strText As String)

    Dim OutApp As Outlook.Application
    Dim OutMail As Outlook.MailItem
    Dim strAttach As String
    Dim blRet As Boolean
   
    strAttach = "C:\TempSnp.snp"
    
  DoCmd.OpenReport "Control2", , , , acHidden
  
DoCmd.OutputTo acReport, strReport, "SnapshotFormat(*.snp)", strAttach, False, ""

DoCmd.Close acReport, "Control2"
   
Dim objOutlSet

Set objOutl = CreateObject("Outlook.Application")
Set objMailItem = objOutl.CreateItem(olMailItem)
'objMailItem.Display
objMailItem.Recipients.Add strEMail

objMailItem.Subject = strSubj
'MsgBox strSubj ' new line
objMailItem.Body = strText
objMailItem.Attachments.Add strAttach
objMailItem.Display

Set objMailItem = Nothing
Set objOutl = Nothing
   
   If Not IsMissing(strAttach) Then
        Kill strAttach
   End If
 
End Function

Answer : Open report hidden for snapshot

Then, is this the code that determines whether or not the report meets the urgency criteria?

Private Sub Report_Activate()
If Me.Critical_Supply.Value = "" Or IsNull(Critical_Supply.Value) Then

        Me.Label76.Visible = False
        Me.Box74.Visible = False
        Else
        Me.Label76.Visible = True
        Me.Box74.Visible = True
        End If
End Sub
___________________________________________________________

Change this:
          If Me.Critical_Supply.Value = "" Or IsNull(Critical_Supply.Value) Then

To this:
         If NZ(Me.Critical_Supply, "") = "" Then                    'easy way to test for nulls and blank spaces

If this doesn't work I would move the above code (as modified) from the Report_Activate event to the Report_Open event.
Random Solutions  
 
programming4us programming4us