If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Second Report not printing - whats wrong with the VBA?
Hi,
I have a control that should allow two reports to be printed. They are basically the same report - different colours and a reprint stamp situated in another location. Via a global variable the two reports should print and use the same query as the bases. What I am getting is the first printing then the second sort of starts and then dies with no result. The following VBA is used. First on is behind the control on the form. The second two are what is behind the reports. Dim stDocName As String Dim stDocName_Blue As String Dim stWcnum As String Dim intPrint As Integer Dim intPrintResp As Integer Dim strWorksNo As String Dim strsql As String Dim rst As DAO.Recordset stWcnum = Me!cboWorksNumberSelect Forms![frmGlobalVariables]![Text0] = stWcnum stDocName = "rptWorksCards" stDocName_Blue = "rptWorksCards_Blue" 'print the green card DoCmd.OpenReport stDocName, acNormal 'print the blue card MsgBox "Printing Blue Card" DoCmd.OpenReport stDocName_Blue, acNormal Set rst = CurrentDb.OpenRecordset("tblWorksCard", dbOpenDynaset) strWorksNo = Forms![frmGlobalVariables]![Text0] strsql = "[Works_Number] = '" & strWorksNo & "'" 'this is text rst.FindFirst strsql If rst![CardPrinted].Value = False Then intPrint = MsgBox("Did both Works Card pages print successfully?", _ vbYesNo + vbQuestion, "Print Status") Select Case intPrint Case vbYes 'Successful print. Mark the 'record accordingly. rst.Edit rst![CardPrinted].Value = True rst.Update Case vbNo 'Print problem. 'DON'T mark the record intPrintResp = MsgBox("Please correct the problem " _ & "and try again .", vbOKOnly + vbExclamation, "Print Status") End Select End If rst.Close Set rst = Nothing Report number 1 Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer) Dim booPrinted As Boolean Dim strsql As String Dim strWorksNumber As String Dim rst As DAO.Recordset 'Look up the Orders Table and determine if the logical field 'booPrinted is true. If so, the user has previously specified 'that the Works Card was successfully printed. The card will 'require the "REPRINT" labels to be visible. 'If the field is false, the labels remain not visible. strWorksNumber = Me!txtWorks_Number strsql = "SELECT tblWorksCard.CardPrinted " strsql = strsql & "FROM tblWorksCard " strsql = strsql & "WHERE (((tblWorksCard.Works_Number) = '" strsql = strsql & strWorksNumber & "'));" Set rst = CurrentDb.OpenRecordset(strsql) rst.MoveFirst booPrinted = rst!CardPrinted.Value If booPrinted Then Me!oleReprint.Visible = True Else Me!oleReprint.Visible = False End If rst.Close Set rst = Nothing End Sub Report Number 2 Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer) Dim booPrinted As Boolean Dim strsql As String Dim strWorksNumber As String Dim rst1 As DAO.Recordset 'Look up the Orders Table and determine if the logical field 'booPrinted is true. If so, the user has previously specified 'that the Works Card was successfully printed. The card will 'require the "REPRINT" labels to be visible. 'If the field is false, the labels remain not visible. strWorksNumber = Me!txtWorks_Number strsql = "SELECT tblWorksCard.CardPrinted " strsql = strsql & "FROM tblWorksCard " strsql = strsql & "WHERE (((tblWorksCard.Works_Number) = '" strsql = strsql & strWorksNumber & "'));" Set rst1 = CurrentDb.OpenRecordset(strsql) rst1.MoveFirst booPrinted = rst1!CardPrinted.Value If booPrinted Then Me!oleReprint1.Visible = True Else Me!oleReprint1.Visible = False End If rst1.Close Set rst1 = Nothing End Sub What would be the cause of the second report not printing. Origianlly they were on the same A3 size report but printed as two pages. Now I want them as two separate reports. Any help and advice apprecaited and I than you in advance. |
#2
|
|||
|
|||
Second Report not printing - whats wrong with the VBA?
Should it be acViewNormal instead of acNormal? I don't know your version of
Acccess but acViewNormal is the correct constant. Billp wrote: DoCmd.OpenReport stDocName, acNormal 'print the blue card MsgBox "Printing Blue Card" DoCmd.OpenReport stDocName_Blue, acNormal -- Please Rate the posting if helps you. Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...ports/200912/1 |
Thread Tools | |
Display Modes | |
|
|