First I will describe what my program does. We receive a CSV file from a customer, massage the data to fit our needs (add a delivery date, consecutive number, etc.), then exports the file in a semicolon delimited format to a printer that prints the information on a 8 1/2 X 14 inch paper. Each record in the file is a seperate page.
I have just modified the access program to 'Double Up', or print 2 pages at once by creating a new file with the same basic structure as the first, except for the fact that the fields are duplicated. This will enable us to now print a 17 X 14 inch form which can be cut in half later.
When the program first enters the sub, I get a 'Sub or Function not defined' error. I have the places where this error occurs in red in my code below.
The reason for the if statement that the error occurs in, is so that when the mailing carton changes (which is based on the Zip Code), we can insert a blank peice of paper (notice the ZZZZZZZZ's). This will help speed up the process of sorting.
I have almost beat my head silly against the wall, and I cant figure it out. Hopefully someone here can tell me what I am doing wrong. Im sorry this post is so long, but I wanted to give you the basic idea of what I am trying to do.
Thanks in advance.
Public Sub Populate_2Up_Table()
Dim DBS As DAO.Database
Dim rst1Up As DAO.Recordset
Dim rst2Up As DAO.Recordset
Dim strTray As String
On Error GoTo Error_Process_2Up
Set DBS = CurrentDb()
Set rst1Up = DBS.OpenRecordset(txtTable, dbOpenDynaset, dbSeeChanges)
Set rst2Up = DBS.OpenRecordset("TwoUp" & txtTable, dbOpenDynaset, dbSeeChanges)
rst1Up.MoveFirst
strTray = rst1Up!field3
Do While rst1Up.EOF <> True
If strTray <> rst1Up!field3 Then Even_Tray_Break
rst2Up.AddNew
rst2Up!DG1 = rst1Up!field1
rst2Up!AutoZip1 = rst1Up!field2
rst2Up!Tray1 = rst1Up!field3
rst2Up!Empty1 = rst1Up!field4
rst2Up!First1 = rst1Up!field5
rst2Up!Last1 = rst1Up!field6
rst2Up!Address1 = rst1Up!field7
rst2Up!City1 = rst1Up!field8
rst2Up!State1 = rst1Up!field9
rst2Up!Zip1 = rst1Up!field10
rst2Up!Barcode1 = rst1Up!field11
rst2Up!Year1 = rst1Up!field13
rst2Up!DelDate1 = rst1Up!DeliverDate
rst2Up!CustID1 = rst1Up!CustomerID
rst2Up!CutOffDate1 = rst1Up!CutOffDate
rst1Up.MoveNext
' If strTray <> rst1Up!field3 Then Odd_Tray_Break
rst2Up!DG2 = rst1Up!field1
rst2Up!AutoZip2 = rst1Up!field2
rst2Up!Tray2 = rst1Up!field3
rst2Up!Empty2 = rst1Up!field4
rst2Up!First2 = rst1Up!field5
rst2Up!Last2 = rst1Up!field6
rst2Up!Address2 = rst1Up!field7
rst2Up!City2 = rst1Up!field8
rst2Up!State2 = rst1Up!field9
rst2Up!Zip2 = rst1Up!field10
rst2Up!Barcode2 = rst1Up!field11
rst2Up!Year2 = rst1Up!field13
rst2Up!DelDate2 = rst1Up!DeliverDate
rst2Up!CustID2 = rst1Up!CustomerID
rst2Up!CutOffDate2 = rst1Up!CutOffDate
rst2Up.Update
rst1Up.MoveNext
Loop
Exit Sub
Even_Tray_Break:
rst2Up.AddNew
rst2Up!DG1 = "ZZZZZZZZ"
rst2Up!AutoZip1 = "ZZZZZZZZ"
rst2Up!Tray1 = "ZZZZZZZZ"
rst2Up!Empty1 = "ZZZZZZZZ"
rst2Up!First1 = "ZZZZZZZZ"
rst2Up!Last1 = "ZZZZZZZZ"
rst2Up!Address1 = "ZZZZZZZZ"
rst2Up!City1 = "ZZZZZZZZ"
rst2Up!State1 = "ZZZZZZZZ"
rst2Up!Zip1 = "ZZZZZZZZ"
rst2Up!Barcode1 = "ZZZZZZZZ"
rst2Up!Year1 = "ZZZZZZZZ"
rst2Up!DelDate1 = "ZZZZZZZZ"
rst2Up!CustID1 = "ZZZZZZZZ"
rst2Up!CutOffDate1 = "ZZZZZZZZ"
rst2Up!DG2 = "ZZZZZZZZ"
rst2Up!AutoZip2 = "ZZZZZZZZ"
rst2Up!Tray2 = "ZZZZZZZZ"
rst2Up!Empty2 = "ZZZZZZZZ"
rst2Up!First2 = "ZZZZZZZZ"
rst2Up!Last2 = "ZZZZZZZZ"
rst2Up!Address2 = "ZZZZZZZZ"
rst2Up!City2 = "ZZZZZZZZ"
rst2Up!State2 = "ZZZZZZZZ"
rst2Up!Zip2 = "ZZZZZZZZ"
rst2Up!Barcode2 = "ZZZZZZZZ"
rst2Up!Year2 = "ZZZZZZZZ"
rst2Up!DelDate2 = "ZZZZZZZZ"
rst2Up!CustID2 = "ZZZZZZZZ"
rst2Up!CutOffDate2 = "ZZZZZZZZ"
rst2Up.Update
rst1Up.MoveNext
strTray = rst1Up!field3
Resume Next
Odd_Tray_Break:
rst2Up!DG2 = "ZZZZZZZZ"
rst2Up!AutoZip2 = "ZZZZZZZZ"
rst2Up!Tray2 = "ZZZZZZZZ"
rst2Up!Empty2 = "ZZZZZZZZ"
rst2Up!First2 = "ZZZZZZZZ"
rst2Up!Last2 = "ZZZZZZZZ"
rst2Up!Address2 = "ZZZZZZZZ"
rst2Up!City2 = "ZZZZZZZZ"
rst2Up!State2 = "ZZZZZZZZ"
rst2Up!Zip2 = "ZZZZZZZZ"
rst2Up!Barcode2 = "ZZZZZZZZ"
rst2Up!Year2 = "ZZZZZZZZ"
rst2Up!DelDate2 = "ZZZZZZZZ"
rst2Up!CustID2 = "ZZZZZZZZ"
rst2Up!CutOffDate2 = "ZZZZZZZZ"
rst2Up.Update
GoTo Even_Tray_Break
Resume Next
Error_Process_2Up:
MsgBox Err.Number & Err.Description
Exit Sub
End Sub
I have just modified the access program to 'Double Up', or print 2 pages at once by creating a new file with the same basic structure as the first, except for the fact that the fields are duplicated. This will enable us to now print a 17 X 14 inch form which can be cut in half later.
When the program first enters the sub, I get a 'Sub or Function not defined' error. I have the places where this error occurs in red in my code below.
The reason for the if statement that the error occurs in, is so that when the mailing carton changes (which is based on the Zip Code), we can insert a blank peice of paper (notice the ZZZZZZZZ's). This will help speed up the process of sorting.
I have almost beat my head silly against the wall, and I cant figure it out. Hopefully someone here can tell me what I am doing wrong. Im sorry this post is so long, but I wanted to give you the basic idea of what I am trying to do.
Thanks in advance.
Public Sub Populate_2Up_Table()
Dim DBS As DAO.Database
Dim rst1Up As DAO.Recordset
Dim rst2Up As DAO.Recordset
Dim strTray As String
On Error GoTo Error_Process_2Up
Set DBS = CurrentDb()
Set rst1Up = DBS.OpenRecordset(txtTable, dbOpenDynaset, dbSeeChanges)
Set rst2Up = DBS.OpenRecordset("TwoUp" & txtTable, dbOpenDynaset, dbSeeChanges)
rst1Up.MoveFirst
strTray = rst1Up!field3
Do While rst1Up.EOF <> True
If strTray <> rst1Up!field3 Then Even_Tray_Break
rst2Up.AddNew
rst2Up!DG1 = rst1Up!field1
rst2Up!AutoZip1 = rst1Up!field2
rst2Up!Tray1 = rst1Up!field3
rst2Up!Empty1 = rst1Up!field4
rst2Up!First1 = rst1Up!field5
rst2Up!Last1 = rst1Up!field6
rst2Up!Address1 = rst1Up!field7
rst2Up!City1 = rst1Up!field8
rst2Up!State1 = rst1Up!field9
rst2Up!Zip1 = rst1Up!field10
rst2Up!Barcode1 = rst1Up!field11
rst2Up!Year1 = rst1Up!field13
rst2Up!DelDate1 = rst1Up!DeliverDate
rst2Up!CustID1 = rst1Up!CustomerID
rst2Up!CutOffDate1 = rst1Up!CutOffDate
rst1Up.MoveNext
' If strTray <> rst1Up!field3 Then Odd_Tray_Break
rst2Up!DG2 = rst1Up!field1
rst2Up!AutoZip2 = rst1Up!field2
rst2Up!Tray2 = rst1Up!field3
rst2Up!Empty2 = rst1Up!field4
rst2Up!First2 = rst1Up!field5
rst2Up!Last2 = rst1Up!field6
rst2Up!Address2 = rst1Up!field7
rst2Up!City2 = rst1Up!field8
rst2Up!State2 = rst1Up!field9
rst2Up!Zip2 = rst1Up!field10
rst2Up!Barcode2 = rst1Up!field11
rst2Up!Year2 = rst1Up!field13
rst2Up!DelDate2 = rst1Up!DeliverDate
rst2Up!CustID2 = rst1Up!CustomerID
rst2Up!CutOffDate2 = rst1Up!CutOffDate
rst2Up.Update
rst1Up.MoveNext
Loop
Exit Sub
Even_Tray_Break:
rst2Up.AddNew
rst2Up!DG1 = "ZZZZZZZZ"
rst2Up!AutoZip1 = "ZZZZZZZZ"
rst2Up!Tray1 = "ZZZZZZZZ"
rst2Up!Empty1 = "ZZZZZZZZ"
rst2Up!First1 = "ZZZZZZZZ"
rst2Up!Last1 = "ZZZZZZZZ"
rst2Up!Address1 = "ZZZZZZZZ"
rst2Up!City1 = "ZZZZZZZZ"
rst2Up!State1 = "ZZZZZZZZ"
rst2Up!Zip1 = "ZZZZZZZZ"
rst2Up!Barcode1 = "ZZZZZZZZ"
rst2Up!Year1 = "ZZZZZZZZ"
rst2Up!DelDate1 = "ZZZZZZZZ"
rst2Up!CustID1 = "ZZZZZZZZ"
rst2Up!CutOffDate1 = "ZZZZZZZZ"
rst2Up!DG2 = "ZZZZZZZZ"
rst2Up!AutoZip2 = "ZZZZZZZZ"
rst2Up!Tray2 = "ZZZZZZZZ"
rst2Up!Empty2 = "ZZZZZZZZ"
rst2Up!First2 = "ZZZZZZZZ"
rst2Up!Last2 = "ZZZZZZZZ"
rst2Up!Address2 = "ZZZZZZZZ"
rst2Up!City2 = "ZZZZZZZZ"
rst2Up!State2 = "ZZZZZZZZ"
rst2Up!Zip2 = "ZZZZZZZZ"
rst2Up!Barcode2 = "ZZZZZZZZ"
rst2Up!Year2 = "ZZZZZZZZ"
rst2Up!DelDate2 = "ZZZZZZZZ"
rst2Up!CustID2 = "ZZZZZZZZ"
rst2Up!CutOffDate2 = "ZZZZZZZZ"
rst2Up.Update
rst1Up.MoveNext
strTray = rst1Up!field3
Resume Next
Odd_Tray_Break:
rst2Up!DG2 = "ZZZZZZZZ"
rst2Up!AutoZip2 = "ZZZZZZZZ"
rst2Up!Tray2 = "ZZZZZZZZ"
rst2Up!Empty2 = "ZZZZZZZZ"
rst2Up!First2 = "ZZZZZZZZ"
rst2Up!Last2 = "ZZZZZZZZ"
rst2Up!Address2 = "ZZZZZZZZ"
rst2Up!City2 = "ZZZZZZZZ"
rst2Up!State2 = "ZZZZZZZZ"
rst2Up!Zip2 = "ZZZZZZZZ"
rst2Up!Barcode2 = "ZZZZZZZZ"
rst2Up!Year2 = "ZZZZZZZZ"
rst2Up!DelDate2 = "ZZZZZZZZ"
rst2Up!CustID2 = "ZZZZZZZZ"
rst2Up!CutOffDate2 = "ZZZZZZZZ"
rst2Up.Update
GoTo Even_Tray_Break
Resume Next
Error_Process_2Up:
MsgBox Err.Number & Err.Description
Exit Sub
End Sub