Unique report ID

  • Thread starter injanib via AccessMonster.com
  • Start date
I

injanib via AccessMonster.com

I have a form that I use to log customer orders. What I need to do is creat a
report of the orders and print it to obtain customer signature upon delivery.
When I log in more orders and then print them I don't want the records that
have already been printed to be printed again. Also for every group of
records that gets printed I like to get a "manifest number" automaticaly
assigned so that if I decide to reprint that manifest I can filter for that
manifest number and print it.
Is this doable??
 
I

injanib via AccessMonster.com

I tried this and it did not work. Even the sample database that I downloaded
did not function properly. It gives an error. "The expression on click you
entered as the event property setting produced the following error: object or
class does not support the set of events. "

Allen said:
See:
Has the record been printed?
at:
http://allenbrowne.com/ser-72.html

The article has a free sample database explaining how to assign the
"manifest number" and print as a batch.
I have a form that I use to log customer orders. What I need to do is creat
a
[quoted text clipped - 8 lines]
manifest number and print it.
Is this doable??
 
A

Allen Browne

Just downloaded it again and tested in Access 2003. Works fine.

Press Ctrl+G and choose Compile on the Debug menu (in the code window.)

Or you may have a problem with references:
http://allenbrowne.com/ser-38.html

Or you may need to start Access with an administrative shortcut
(particularly if using Windows Vista):
http://allenbrowne.com/bug-17.html#RunAsAdmin

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

injanib via AccessMonster.com said:
I tried this and it did not work. Even the sample database that I
downloaded
did not function properly. It gives an error. "The expression on click you
entered as the event property setting produced the following error: object
or
class does not support the set of events. "

Allen said:
See:
Has the record been printed?
at:
http://allenbrowne.com/ser-72.html

The article has a free sample database explaining how to assign the
"manifest number" and print as a batch.
I have a form that I use to log customer orders. What I need to do is
creat
a
[quoted text clipped - 8 lines]
manifest number and print it.
Is this doable??
 
I

injanib via AccessMonster.com

Ok, I got it working. But I had to manipulate the codes to fit my preferences.


instead of having two buttons I only have one. And I do not have a list box
to make a selection for filtering.

My button first generates the number and automatically populates the report.
However It does not filter for the highest batch number. Here is my codes.

I suspect an error in this line. (strWhere = varBatchID). Not sure if I have
it right.

Option Compare Database
Option Explicit

Private Sub PrintManifest_Click()

'On Error GoTo Err_Handler
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSql As String
Dim lngBatchID As Long
Dim lngKt As Long
Dim varBatchID As Variant
Dim strWhere As String
Const strcDoc = "Manifest"

'Create the new batch, and get the number.
Set db = CurrentDb()
Set rs = db.OpenRecordset("tblBatch", dbOpenDynaset, dbAppendOnly)
rs.AddNew
rs!DateTime = Now()
lngBatchID = rs!BatchID
rs.Update
rs.Close

'Give this batch number to all members who have not been printed.
strSql = "UPDATE Tracking SET BatchID = " & lngBatchID & " WHERE BatchID
Is Null;"
db.Execute strSql, dbFailOnError
lngKt = db.RecordsAffected

'select the highest batch
varBatchID = DMax("BatchID", "tblBatch")

'if the report is already open. close it.
If CurrentProject.AllReports(strcDoc).IsLoaded Then
DoCmd.Close acReport, strcDoc
End If

'Open it filtered for the highest batch number
strWhere = varBatchID
DoCmd.OpenReport strcDoc, acViewPreview, , strWhere


Exit_Handler:
Set rs = Nothing
Set db = Nothing
Exit Sub

Err_Handler:
MsgBox "Error " & Err.Number & ": " & Err.Description, vbExclamation,
"PrintManifest_Click()"
Resume Exit_Handler
End Sub

Allen said:
Just downloaded it again and tested in Access 2003. Works fine.

Press Ctrl+G and choose Compile on the Debug menu (in the code window.)

Or you may have a problem with references:
http://allenbrowne.com/ser-38.html

Or you may need to start Access with an administrative shortcut
(particularly if using Windows Vista):
http://allenbrowne.com/bug-17.html#RunAsAdmin
I tried this and it did not work. Even the sample database that I
downloaded
[quoted text clipped - 17 lines]
 
A

Allen Browne

There WhereCondition string needs to look like the WHERE clause in a query,
so you need:
strWhere = "[BatchID] = " & lngBatchID

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

injanib via AccessMonster.com said:
Ok, I got it working. But I had to manipulate the codes to fit my
preferences.


instead of having two buttons I only have one. And I do not have a list
box
to make a selection for filtering.

My button first generates the number and automatically populates the
report.
However It does not filter for the highest batch number. Here is my codes.

I suspect an error in this line. (strWhere = varBatchID). Not sure if I
have
it right.

Option Compare Database
Option Explicit

Private Sub PrintManifest_Click()

'On Error GoTo Err_Handler
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSql As String
Dim lngBatchID As Long
Dim lngKt As Long
Dim varBatchID As Variant
Dim strWhere As String
Const strcDoc = "Manifest"

'Create the new batch, and get the number.
Set db = CurrentDb()
Set rs = db.OpenRecordset("tblBatch", dbOpenDynaset, dbAppendOnly)
rs.AddNew
rs!DateTime = Now()
lngBatchID = rs!BatchID
rs.Update
rs.Close

'Give this batch number to all members who have not been printed.
strSql = "UPDATE Tracking SET BatchID = " & lngBatchID & " WHERE
BatchID
Is Null;"
db.Execute strSql, dbFailOnError
lngKt = db.RecordsAffected

'select the highest batch
varBatchID = DMax("BatchID", "tblBatch")

'if the report is already open. close it.
If CurrentProject.AllReports(strcDoc).IsLoaded Then
DoCmd.Close acReport, strcDoc
End If

'Open it filtered for the highest batch number
strWhere = varBatchID
DoCmd.OpenReport strcDoc, acViewPreview, , strWhere


Exit_Handler:
Set rs = Nothing
Set db = Nothing
Exit Sub

Err_Handler:
MsgBox "Error " & Err.Number & ": " & Err.Description, vbExclamation,
"PrintManifest_Click()"
Resume Exit_Handler
End Sub

Allen said:
Just downloaded it again and tested in Access 2003. Works fine.

Press Ctrl+G and choose Compile on the Debug menu (in the code window.)

Or you may have a problem with references:
http://allenbrowne.com/ser-38.html

Or you may need to start Access with an administrative shortcut
(particularly if using Windows Vista):
http://allenbrowne.com/bug-17.html#RunAsAdmin
I tried this and it did not work. Even the sample database that I
downloaded
[quoted text clipped - 17 lines]
manifest number and print it.
Is this doable??
 
I

injanib via AccessMonster.com

Is this goingt to exclude batch numbers that have already been printed?
I want the code to pick up the highest batch number and print so that I only
get the batch that have not been printed yet.

Allen said:
There WhereCondition string needs to look like the WHERE clause in a query,
so you need:
strWhere = "[BatchID] = " & lngBatchID
Ok, I got it working. But I had to manipulate the codes to fit my
preferences.
[quoted text clipped - 81 lines]
 
A

Allen Browne

Try it.

The code creates a new batch, and assigns the number to the variable
lngBatchID. There WhereCondition then limits the report to this *one* batch.
 
I

injanib via AccessMonster.com

Perfect. Thanks allot


Allen said:
Try it.

The code creates a new batch, and assigns the number to the variable
lngBatchID. There WhereCondition then limits the report to this *one* batch.
 
I

injanib via AccessMonster.com

Actually one more thing. I have a field called floor number in my form. If I
want to print this report sorted by the floor number such that each floor's
records are printed on seperate sheet. Meaning no records with different
floor numbers on the same sheet.
injanib said:
Perfect. Thanks allot
[quoted text clipped - 5 lines]
 
A

Allen Browne

In report design view, open the Sorting And Grouping dialog (View menu.)

Choose the Floor Number field, and in the lower pane of the dialog, set
Group Header to Yes. Access adds a new section to the report.

Right-click that section, and choose Properties.
Set the Force New Page property to: Before Section.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

injanib via AccessMonster.com said:
Actually one more thing. I have a field called floor number in my form. If
I
want to print this report sorted by the floor number such that each
floor's
records are printed on seperate sheet. Meaning no records with different
floor numbers on the same sheet.
injanib said:
Perfect. Thanks allot
[quoted text clipped - 5 lines]
only
get the batch that have not been printed yet.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top