M
Mario
Hi ,
I have an Access application that prints a number of waybills for
several clients .
On a form i can select the client and add the number of waybills they
need.
(for example : HP - 100 waybills)
Now I need to add an incremental number on each waybill that is
printed.
I have another table called "tblCounter" with 1 field 'CounterNo".
I'd like to use the counter to start the numbering on the waybills and
update the counter when the reports are printed.
Can someone help me with this pls.
This is the code i use now.
Sub PrintWaybill()
Dim Language
Dim dbWaybill As DAO.Database
Dim rstCurWB As DAO.Recordset
Dim RecId, Aantal, RecCount
Set dbWaybill = CurrentDb()
Set rstCurWB = dbWaybill.OpenRecordset("QryPrintSelected",
dbOpenDynaset)
With rstCurWB
RecCount = .RecordCount
End With
If RecCount = 0 Or IsNull(RecCount) Or IsEmpty(RecCount) Then
MsgBox "No clients selected to print", vbInformation +
vbOKOnly, "Error Printing"
Else
rstCurWB.MoveFirst
While Not rstCurWB.EOF
RecId = rstCurWB.Fields("OrderID").Value
Aantal = rstCurWB.Fields("AantalAWB").Value ' number of
waybills needed
DoCmd.OpenReport "RptNewWaybill", acViewPreview, ,
"[OrderID]=" & RecId, acHidden
DoCmd.SelectObject acReport, "RptNewWaybill", False
DoCmd.PrintOut , , , , Aantal
DoCmd.Close acReport, "RptNewWaybill", acSaveNo
rstCurWB.Edit
rstCurWB.Fields("PrintAWB") = False
rstCurWB.Fields("AantalAWB") = 0
rstCurWB.Update
rstCurWB.MoveNext
Wend
End If
End Sub
I have an Access application that prints a number of waybills for
several clients .
On a form i can select the client and add the number of waybills they
need.
(for example : HP - 100 waybills)
Now I need to add an incremental number on each waybill that is
printed.
I have another table called "tblCounter" with 1 field 'CounterNo".
I'd like to use the counter to start the numbering on the waybills and
update the counter when the reports are printed.
Can someone help me with this pls.
This is the code i use now.
Sub PrintWaybill()
Dim Language
Dim dbWaybill As DAO.Database
Dim rstCurWB As DAO.Recordset
Dim RecId, Aantal, RecCount
Set dbWaybill = CurrentDb()
Set rstCurWB = dbWaybill.OpenRecordset("QryPrintSelected",
dbOpenDynaset)
With rstCurWB
RecCount = .RecordCount
End With
If RecCount = 0 Or IsNull(RecCount) Or IsEmpty(RecCount) Then
MsgBox "No clients selected to print", vbInformation +
vbOKOnly, "Error Printing"
Else
rstCurWB.MoveFirst
While Not rstCurWB.EOF
RecId = rstCurWB.Fields("OrderID").Value
Aantal = rstCurWB.Fields("AantalAWB").Value ' number of
waybills needed
DoCmd.OpenReport "RptNewWaybill", acViewPreview, ,
"[OrderID]=" & RecId, acHidden
DoCmd.SelectObject acReport, "RptNewWaybill", False
DoCmd.PrintOut , , , , Aantal
DoCmd.Close acReport, "RptNewWaybill", acSaveNo
rstCurWB.Edit
rstCurWB.Fields("PrintAWB") = False
rstCurWB.Fields("AantalAWB") = 0
rstCurWB.Update
rstCurWB.MoveNext
Wend
End If
End Sub