PC Review


Reply
Thread Tools Rate Thread

Second Report not printing - whats wrong with the VBA I have??????

 
 
Billp
Guest
Posts: n/a
 
      9th Dec 2009
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 hidden form and global variable the two
reports should
print and use the same query as the basies. 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 one is behind the control on the form.
The second two are what is behind the reports.
Have I gone about this the wrong way?

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?

Originally they were on the same A3 size report but printed as two pages.
Now I want them as two separate reports.
Don’t know what to do.
Any help and advice appreciated and I than you in advance.

 
Reply With Quote
 
 
 
 
Billp
Guest
Posts: n/a
 
      11th Dec 2009
And the answer is - a spelling mistake and a field that need to be changed on
the form.
Me!txtWorks_Number did not exist on the second form but was text13


arrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr

"Billp" wrote:

> 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 hidden form and global variable the two
> reports should
> print and use the same query as the basies. 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 one is behind the control on the form.
> The second two are what is behind the reports.
> Have I gone about this the wrong way?
>
> 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?
>
> Originally they were on the same A3 size report but printed as two pages.
> Now I want them as two separate reports.
> Don’t know what to do.
> Any help and advice appreciated and I than you in advance.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Second Report not printing - whats wrong with the VBA? Billp Microsoft Access Reports 0 9th Dec 2009 01:13 AM
VBA Recording wrong... whats the deal? McManCSU Microsoft Excel Programming 1 17th Jun 2005 01:23 PM
Sp2 does not show up in AutoUpdate ?? whats wrong ? OCZ Guy Windows XP Help 2 25th Aug 2004 09:13 AM
not sure whats wrong with time calculation =?Utf-8?B?RGVyZWs=?= Microsoft Access Form Coding 3 30th Apr 2004 11:36 PM
Whats wrong with this VBA statement -ActiveCell.FormulaR1C1...? =?Utf-8?B?aGFs?= Microsoft Excel Programming 5 8th Nov 2003 03:48 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:39 PM.