Question : Docmd.printout Access 2007 not printing

Hi All,

I have an access DB that I have writtenf or my company. It works fine for all client version up to but NOT including 2007, on one particular bit.

Basiccly there is a complex print function that runs when they opt to print a certain document. The program creates a SQL string then applies it to a pass thru query and there is a report that is built off the source of this query which is run using the docmd.printout.

My problem is when this runs, you see the small print box pop up which shows the report name that its printing and the printer its going to.. however when you expect to see the number of pages wiz past quickly and for it to start print... it doesnt the little print box dissapears and nothing prints off.


There is some other ode that handles calling the function i have attached and there is some code in the report. I will link that if required.

This works perfectly fine on older than 2007 clients.

Here is my code that controls the actual print out : -
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:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
Private Function Print_pick(rpt_name)
    '===========================================================================
    'This function is called from the picklists button, it will print the picklists
    'on the report that it has been sent as rpt_name
    '===========================================================================
    '======Call functions to prepare the text for the reports====
   On Error GoTo Print_pick_Error
 
    Pre_Set_oText
    Pre_Set_Text
    Pre_Set_iText
    '============================================================
    Dim db As dao.Database
    Dim qdf As dao.QueryDef
    Dim StrSQL As String
    Dim xOrders, xOrdArry, stdocname
    Dim xCheck
    
    ' Identify the database and assign it to the variable
    Set db = CurrentDb
    ' Check for the existence of the query, create it if not found,
    ' and assign it to the variable
    If Not QueryExists("pt_rpt_pick_list_std") Then
        Set qdf = db.CreateQueryDef("pt_rpt_pick_list_std")
    Else
        Set qdf = db.QueryDefs("pt_rpt_pick_list_std")
    End If
    ' Need to get the list of orders
    xOrders = RTrim(LTrim(Trim(GetOrders)))
    xOrdArry = Replace(xOrders, " ;", "','")
    'MsgBox xOrdArry
    Debug.Print xOrdArry
    ' Build the SQL string
    
    StrSQL = "SELECT DISTINCT " & _
            "TOP 100 PERCENT dbo.tbl_OHeader.DDNAM, dbo.tbl_OHeader.ADAD1, dbo.tbl_OHeader.ADAD2, dbo.tbl_OHeader.ADAD3, dbo.tbl_OHeader.ADAD4, " & _
            "dbo.tbl_OHeader.ADPC1, dbo.tbl_OHeader.ADPC2, dbo.tbl_OHeader.DCNAM, dbo.tbl_OHeader.ACAD1, dbo.tbl_OHeader.ACAD2, " & _
            "dbo.tbl_OHeader.ACAD3, dbo.tbl_OHeader.ACAD4, dbo.tbl_OHeader.ACPC1, dbo.tbl_OHeader.ACPC2, dbo.tbl_OHeader.BATCH_OI_NO, " & _
            "dbo.tbl_OHeader.GRUTE1, dbo.tbl_OHeader.ECSTNC, dbo.tbl_OHeader.EDTNOC, dbo.tbl_OHeader.EORNO, dbo.tbl_OHeader.GORTP, " & _
            "dbo.tbl_OLine.LORDS4, dbo.tbl_OLine.ITEM, dbo.tbl_OLine.DITMD, dbo.tbl_OLine.QGWGT, dbo.tbl_OLine.MUDN3, dbo.tbl_OLine.UOMTU, " & _
            "dbo.tbl_OHeader.[@SOVD], dbo.tbl_OHeader.DSCRF1, dbo.tbl_OHeader.ESRPP, dbo.tbl_OHeader.ESRPS, dbo.tbl_OLine.QREQB, " & _
            "dbo.tbl_OText.DTEXT1 , dbo.tbl_trans.trans_delNo, dbo.tbl_trans.trans_customer, dbo.tbl_trans.trans_loadid, dbo.tbl_trans.trans_value, dbo.tbl_oline.itmrr6, Case When IsNumeric(Left(dbo.tbl_OLine.ITEM + ' ',1)) = 1 Then 1 Else 0 End AS Expr1037, dbo.tbl_OLine.ITEM, 0 AS [£TOVL], dbo.tbl_oHeader.batch_number " & _
            "FROM dbo.tbl_OHeader INNER JOIN " & _
            "dbo.tbl_OLine ON dbo.tbl_OHeader.BATCH_OI_NO = dbo.tbl_OLine.BATCH_OI_NO LEFT OUTER JOIN " & _
            "dbo.tbl_trans ON dbo.tbl_OHeader.BATCH_OI_NO = dbo.tbl_trans.trans_orderno LEFT OUTER JOIN " & _
            "dbo.tbl_OText ON dbo.tbl_OLine.BATCH_OI_NO = dbo.tbl_OText.EORNO3 AND dbo.tbl_OLine.LORDS4 = dbo.tbl_OText.LORDS1 " & _
            "WHERE (dbo.tbl_OHeader.BATCH_OI_NO IN ('" & xOrdArry & "')) AND (dbo.tbl_trans.trans_loadid = '" & GetLoadNo & "') " & _
            "ORDER BY Case When IsNumeric(Left(dbo.tbl_OLine.ITEM + ' ',1)) = 1 Then 1 Else 0 End, dbo.tbl_OLine.ITEM"
    
    'InputBox "", "", strSQL
    
    ' Pass the SQL string to the query
    qdf.sql = StrSQL
    ' Turn off screen updating
    'DoCmd.Echo False
    stdocname = Trim(rpt_name)
    
    'Is Pick Printing enabled?
    'Dr Nick friendly :P
    '==========================
    xCheck = CheckConfig("pick_print_on")
    
    If xCheck = vbTrue Then
        DoCmd.SelectObject acReport, stdocname, True
        DoCmd.PrintOut acPrintAll, , , , CheckConfig("print_copies_draft_pick")
        'DoCmd.OpenReport stdocname, acViewNormal
    End If
 
   On Error GoTo 0
   Exit Function
 
Print_pick_Error:
    Call ErrorLog(Err.Description, Err.Number, Me.Name, "Print_pick")
    'MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Print_pick of VBA Document Form_frm_load_preview"
End Function
Open in New Window Select All

Answer : Docmd.printout Access 2007 not printing

To add to it a thing i noticed is when the print box opens up briefly and it looks like its going to work but doesnt the bubble from the system tray also birefly flashes up as if it thought for a second about printing then fades away before it becomes fully visible.

I also would like to add that its a vista machine running SP1 and office is on Sp1 as well.

If i do the following :

Docmd.openreport stdocname, acpreview
DoCmd.SelectObject acReport, stdocname, True
DoCmd.PrintOut acPrintAll, , , , CheckConfig("print_copies_draft_pick")
Docmd.close acreport, stdocname

It prints the report correctly albeit the screen is a bit screwy with everything opening etc.

Why i have no idea?!

I would also prefer to solve this problem rather than doing my above fix!

Thank you for your help so far :D
Random Solutions  
 
programming4us programming4us