Pre-Print Purchase Orders

J

Josh

Boss didn't want to use Autonumber for PO number, since he didn't want
any "skipped" PO numbers. (which means that he has to "void" each
unused PO, but thats what he wants).

On my Purchase Order Form, I have:

Private Sub Form_Current()
If Me.NewRecord Then
Me.PONumber = 1 + DMax("ponumber", "tblpurchaseorders")
Me.Reviewed = -1
Me.cboDepartment = "DefaultDeparment"
Me.Dirty = False
End If
Exit Sub

which works well. Now I'm asked to: Be able to Pre-Print blank PO's,
like the pad of blank PO's they used to give out to a few Departments
to let them print their own PO. Now, they'll print them, but they will
at least be in the 'system' for later followup.

How can I pre-print a set number of blank PO's? I have the blank PO
made, rptBlankPO.

I've made a Form which has an unbound text bo (txtPOblankPrint) for
number or blanks to print, and cboDepartment. What code would I put
in a cmd button?

Something like: (lets say we enter 25 in txtPOblankPrint)

dim POPrintNumber as long
POPrintNumber = me.txtPOblankPrint 'seems like this is needed, just
not sure how to use

Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("tblPurchaseOrders", dbOpenDynaset)
rs.AddNew
rs!POnumber = 1 + DMax("ponumber", "tblpurchaseorders")
rs!Department = me.cboDepartment
rs.Update
rs.Close
Set rs = Nothing
Set db = Nothing

How would I keep addings records untill I've added 25 new records?

And, also, while I could probably figure out how to print those
'blank' POs, it would be a separate procedure, probably. Is there
some additional code to print the 25 as part of this procedure?

Thanks, Josh
 
A

Al Campagna

Josh,
Not sure I understand the reasoning behind dropping the auto number. As long as
records are not deleted, there should be no "skipped" autonumbers. Using DMax +1 will be
susceptible to the same skipping, as long as someone is allowed to delete POs.
Also, does your question about printing "blank" POs involve PO numbering? If so, I
think your in for real problems...

On my website below (Access Tips), I have a 97 and 2003 sample file that shows how to
print any number of duplicate labels (or reports). (PO numbering not included)
 
J

Josh

Not sure I understand the reasoning behind dropping the auto number. As long as
records are not deleted, there should be no "skipped" autonumbers. Using DMax +1 will be
susceptible to the same skipping, as long as someone is allowed to delete POs.

Thanks for the reply. I personally don't see a problem in using autonumbers,
but Boss doesn't want any 'skips'. The purcharse order form's "can delete" is
set to No.
Also, does your question about printing "blank" POs involve PO numbering? If so, I
think your in for real problems...

Yes, it does print the PO numbers on them. I set a yes/no field to show that
this is a "pre-printed" PO, and will follow-up based on that. What other
problems do I need to lookout for?

I've cobbled together the code below, and it seems to work. This will not be a
multi-user environment (there will be 'requests' from multi-users, but not the
actual issueing of the POs) so I shouldn't have the problem of number being used
by someone else while in the middle of this procedure.

But I'm uncertain about a few things:
1. My Dim statements, I used Long, and they seem to work, but should I use
something else?
2.Error handling, I have the access wizard type error handling, but it seems
like there should be some additional error handling in the rs.addnew section.
But, with the Next statement, I'm confused as to where I would add any Resume
Next statements (if any) for error handling,
3. Error handling aside, there just seems to be something I'm missing, after the
Next statement, it seems like there should be something more there.


Private Sub Command156_Click()
On Error GoTo Err_Command156_Click

Dim NumberToPrint As Long
Dim iCount As Long

NumberToPrint = Me.txtPrintNumber

'txtGetCurrentMax is hidden text box on PurchaseOrder Form
Me.txtGetCurrentMax = DMax("POnumber", "tblPurchaseOrders")

For iCount = 1 To NumberToPrint Step 1

Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("tblPurchaseOrders", dbOpenDynaset)

rs.AddNew
rs!PONumber = 1 + DMax("POnumber", "tblPurchaseOrders")
rs!Department = Me.cboDepartment.Column(0)
rs.Update
rs.Close

Set rs = Nothing
Set db = Nothing

Next

'now print the blank PO's (blank except for PO#s/Dept's)

Private Sub Command156_Click()
On Error GoTo Err_Command156_Click

Dim NumberToPrint As Long
Dim iCount As Long

'txtPrintNumber is the unbound text box for User's input
NumberToPrint = Me.txtPrintNumber

'txtGetCurrentMax is hidden text box on PurchaseOrder Form
Me.txtGetCurrentMax = DMax("POnumber", "tblPurchaseOrders")

For iCount = 1 To NumberToPrint Step 1

Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("tblPurchaseOrders", dbOpenDynaset)

rs.AddNew
rs!PONumber = 1 + DMax("POnumber", "tblPurchaseOrders")
rs!Department = Me.cboDepartment.Column(0)
rs.Update
rs.Close

Set rs = Nothing
Set db = Nothing

Next

'now print the blank PO's (blank except for PO#s/Dept's)

'this rpt's record source is query with POnumber's critiera
'being: > [txtGetCurrentMax] on the PO form.

DoCmd.OpenReport "rptPurchaseOrdersBlanks"

Exit_Command156_Click:
Exit Sub

Err_Command156_Click:
MsgBox Err.Description
Resume Exit_Command156_Click
End Sub


Anyone notice any glaring problems with this? Or offer suggestions on better
ways of doing this?

Thanks, Josh
 
J

Josh

Looks like I messed up on my copy/paste, got a multiple paste in that code, here
is the code:


Private Sub Command156_Click()
On Error GoTo Err_Command156_Click

Dim NumberToPrint As Long
Dim iCount As Long

'txtPrintNumber is the unbound text box for User's input
NumberToPrint = Me.txtPrintNumber

'txtGetCurrentMax is hidden text box on PurchaseOrder Form
Me.txtGetCurrentMax = DMax("POnumber", "tblPurchaseOrders")

For iCount = 1 To NumberToPrint Step 1

Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("tblPurchaseOrders", dbOpenDynaset)

rs.AddNew
rs!PONumber = 1 + DMax("POnumber", "tblPurchaseOrders")
rs!Department = Me.cboDepartment.Column(0)
rs.Update
rs.Close

Set rs = Nothing
Set db = Nothing

Next

'now print the blank PO's (blank except for PO#s/Dept's)

'this rpt's record source is query with POnumber's critiera
'being: > [txtGetCurrentMax] on the PO form.

DoCmd.OpenReport "rptPurchaseOrdersBlanks"

Exit_Command156_Click:
Exit Sub

Err_Command156_Click:
MsgBox Err.Description
Resume Exit_Command156_Click
End Sub
 
A

Al Campagna

Josh,
OK, I still say that an autonumber (with a bit of form coding) will not skip
numbers... but... your DMax method should be OK too.

1. Nothing "wrong" with Long, though Integer would probably suffice.
2. Not sure if that's needed. If what you have works, that should do it.
3. Re the Next... (not critical, but)
Declare all your Dims and Sets before the For/Next
Looks as though your closing and reopening the rs. on each iCount... try
this...
Set db = CurrentDb
Set rs = db.OpenRecordset("tblPurchaseOrders", dbOpenDynaset)
For iCount = 1 To NumberToPrint Step 1
rs.AddNew
rs!PONumber = 1 + DMax("POnumber", "tblPurchaseOrders")
rs!Department = Me.cboDepartment.Column(0)
rs.Update
Next iCount
Set rs = Nothing
Set db = Nothing

The iterated AddNew should set up the next add without closing/reopening the rs. each
time.
------------------------------------------------
Since you're using the form's recordset, leave it that way. I'd use a dilaog form with
that could be run at any time, standalone.
BeginningPO = DMax(yada yada) + 1
NoOfBlankPOs = (user entry field)
EndingPO = BeginningPO + NoOfBlankPOs
cboDept = (a combo selection)
That way you could use...
For iCount = BeginningPO to EndingPO Step1
rs!PONumber = iCount '(avoiding the DMax aggreagate function)
and the report query could be filtered by...
Between Forms!frmDialog!BeginningPO and Forms!frmDialog!EndingPO

Please test on a copy of the form...
--
hth
Al Campagna
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions


But I'm uncertain about a few things:
1. My Dim statements, I used Long, and they seem to work, but should I use
something else?
2.Error handling, I have the access wizard type error handling, but it seems
like there should be some additional error handling in the rs.addnew section.
But, with the Next statement, I'm confused as to where I would add any Resume
Next statements (if any) for error handling,
3. Error handling aside, there just seems to be something I'm missing, after the
Next statement, it seems like there should be something more there.


Private Sub Command156_Click()
On Error GoTo Err_Command156_Click

Dim NumberToPrint As Long
Dim iCount As Long

NumberToPrint = Me.txtPrintNumber

'txtGetCurrentMax is hidden text box on PurchaseOrder Form
Me.txtGetCurrentMax = DMax("POnumber", "tblPurchaseOrders")

For iCount = 1 To NumberToPrint Step 1

Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("tblPurchaseOrders", dbOpenDynaset)

rs.AddNew
rs!PONumber = 1 + DMax("POnumber", "tblPurchaseOrders")
rs!Department = Me.cboDepartment.Column(0)
rs.Update
rs.Close

Set rs = Nothing
Set db = Nothing

Next

'now print the blank PO's (blank except for PO#s/Dept's)

Private Sub Command156_Click()
On Error GoTo Err_Command156_Click

Dim NumberToPrint As Long
Dim iCount As Long

'txtPrintNumber is the unbound text box for User's input
NumberToPrint = Me.txtPrintNumber

'txtGetCurrentMax is hidden text box on PurchaseOrder Form
Me.txtGetCurrentMax = DMax("POnumber", "tblPurchaseOrders")

For iCount = 1 To NumberToPrint Step 1

Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("tblPurchaseOrders", dbOpenDynaset)

rs.AddNew
rs!PONumber = 1 + DMax("POnumber", "tblPurchaseOrders")
rs!Department = Me.cboDepartment.Column(0)
rs.Update
rs.Close

Set rs = Nothing
Set db = Nothing

Next

'now print the blank PO's (blank except for PO#s/Dept's)

'this rpt's record source is query with POnumber's critiera
'being: > [txtGetCurrentMax] on the PO form.

DoCmd.OpenReport "rptPurchaseOrdersBlanks"

Exit_Command156_Click:
Exit Sub

Err_Command156_Click:
MsgBox Err.Description
Resume Exit_Command156_Click
End Sub


Anyone notice any glaring problems with this? Or offer suggestions on better
ways of doing this?

Thanks, Josh
 
D

David F Cox

OK, I still say that an autonumber (with a bit of form coding) will not
skip numbers...

do a google newgroup search on "autonumber problem".

Al Campagna said:
Josh,
OK, I still say that an autonumber (with a bit of form coding) will not
skip numbers... but... your DMax method should be OK too.

1. Nothing "wrong" with Long, though Integer would probably suffice.
2. Not sure if that's needed. If what you have works, that should do
it.
3. Re the Next... (not critical, but)
Declare all your Dims and Sets before the For/Next
Looks as though your closing and reopening the rs. on each
iCount... try this...
Set db = CurrentDb
Set rs = db.OpenRecordset("tblPurchaseOrders", dbOpenDynaset)
For iCount = 1 To NumberToPrint Step 1
rs.AddNew
rs!PONumber = 1 + DMax("POnumber", "tblPurchaseOrders")
rs!Department = Me.cboDepartment.Column(0)
rs.Update
Next iCount
Set rs = Nothing
Set db = Nothing

The iterated AddNew should set up the next add without
closing/reopening the rs. each time.
------------------------------------------------
Since you're using the form's recordset, leave it that way. I'd use a
dilaog form with that could be run at any time, standalone.
BeginningPO = DMax(yada yada) + 1
NoOfBlankPOs = (user entry field)
EndingPO = BeginningPO + NoOfBlankPOs
cboDept = (a combo selection)
That way you could use...
For iCount = BeginningPO to EndingPO Step1
rs!PONumber = iCount '(avoiding the DMax aggreagate function)
and the report query could be filtered by...
Between Forms!frmDialog!BeginningPO and Forms!frmDialog!EndingPO

Please test on a copy of the form...
--
hth
Al Campagna
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions


But I'm uncertain about a few things:
1. My Dim statements, I used Long, and they seem to work, but should I
use
something else?
2.Error handling, I have the access wizard type error handling, but it
seems
like there should be some additional error handling in the rs.addnew
section.
But, with the Next statement, I'm confused as to where I would add any
Resume
Next statements (if any) for error handling,
3. Error handling aside, there just seems to be something I'm missing,
after the
Next statement, it seems like there should be something more there.


Private Sub Command156_Click()
On Error GoTo Err_Command156_Click

Dim NumberToPrint As Long
Dim iCount As Long

NumberToPrint = Me.txtPrintNumber

'txtGetCurrentMax is hidden text box on PurchaseOrder Form
Me.txtGetCurrentMax = DMax("POnumber", "tblPurchaseOrders")

For iCount = 1 To NumberToPrint Step 1

Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("tblPurchaseOrders", dbOpenDynaset)

rs.AddNew
rs!PONumber = 1 + DMax("POnumber", "tblPurchaseOrders")
rs!Department = Me.cboDepartment.Column(0)
rs.Update
rs.Close

Set rs = Nothing
Set db = Nothing

Next

'now print the blank PO's (blank except for PO#s/Dept's)

Private Sub Command156_Click()
On Error GoTo Err_Command156_Click

Dim NumberToPrint As Long
Dim iCount As Long

'txtPrintNumber is the unbound text box for User's input
NumberToPrint = Me.txtPrintNumber

'txtGetCurrentMax is hidden text box on PurchaseOrder Form
Me.txtGetCurrentMax = DMax("POnumber", "tblPurchaseOrders")

For iCount = 1 To NumberToPrint Step 1

Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("tblPurchaseOrders", dbOpenDynaset)

rs.AddNew
rs!PONumber = 1 + DMax("POnumber", "tblPurchaseOrders")
rs!Department = Me.cboDepartment.Column(0)
rs.Update
rs.Close

Set rs = Nothing
Set db = Nothing

Next

'now print the blank PO's (blank except for PO#s/Dept's)

'this rpt's record source is query with POnumber's critiera
'being: > [txtGetCurrentMax] on the PO form.

DoCmd.OpenReport "rptPurchaseOrdersBlanks"

Exit_Command156_Click:
Exit Sub

Err_Command156_Click:
MsgBox Err.Description
Resume Exit_Command156_Click
End Sub


Anyone notice any glaring problems with this? Or offer suggestions on
better
ways of doing this?

Thanks, Josh
 
J

Josh

Aaarrgh.....thats what I get for working on this at 1:00am, looks like
I didn't REPLY, instead made a new topic.......

I humbly apologize.........

Here is code without the extra "paste"....


Private Sub Command156_Click()
On Error GoTo Err_Command156_Click

Dim NumberToPrint As Long
Dim iCount As Long

'txtPrintNumber is the unbound text box for User's input
NumberToPrint = Me.txtPrintNumber

'txtGetCurrentMax is hidden text box on PurchaseOrder Form
Me.txtGetCurrentMax = DMax("POnumber", "tblPurchaseOrders")

For iCount = 1 To NumberToPrint Step 1

Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("tblPurchaseOrders", dbOpenDynaset)

rs.AddNew
rs!PONumber = 1 + DMax("POnumber", "tblPurchaseOrders")
rs!Department = Me.cboDepartment.Column(0)
rs.Update
rs.Close

Set rs = Nothing
Set db = Nothing

Next

'now print the blank PO's (blank except for PO#s/Dept's)

'this rpt's record source is query with POnumber's critiera
'being: > [txtGetCurrentMax] on the PO form.

DoCmd.OpenReport "rptPurchaseOrdersBlanks"

Exit_Command156_Click:
Exit Sub

Err_Command156_Click:
MsgBox Err.Description
Resume Exit_Command156_Click
End Sub


Not sure I understand the reasoning behind dropping the auto number. As long as
records are not deleted, there should be no "skipped" autonumbers. Using DMax +1 will be
susceptible to the same skipping, as long as someone is allowed to delete POs.

Thanks for the reply. I personally don't see a problem in using autonumbers,
but Boss doesn't want any 'skips'. The purcharse order form's "can delete" is
set to No.
Also, does your question about printing "blank" POs involve PO numbering? If so, I
think your in for real problems...

Yes, it does print the PO numbers on them. I set a yes/no field to show that
this is a "pre-printed" PO, and will follow-up based on that. What other
problems do I need to lookout for?

I've cobbled together the code below, and it seems to work. This will not be a
multi-user environment (there will be 'requests' from multi-users, but not the
actual issueing of the POs) so I shouldn't have the problem of number being used
by someone else while in the middle of this procedure.

But I'm uncertain about a few things:
1. My Dim statements, I used Long, and they seem to work, but should I use
something else?
2.Error handling, I have the access wizard type error handling, but it seems
like there should be some additional error handling in the rs.addnew section.
But, with the Next statement, I'm confused as to where I would add any Resume
Next statements (if any) for error handling,
3. Error handling aside, there just seems to be something I'm missing, after the
Next statement, it seems like there should be something more there.


Private Sub Command156_Click()
On Error GoTo Err_Command156_Click

Dim NumberToPrint As Long
Dim iCount As Long

NumberToPrint = Me.txtPrintNumber

'txtGetCurrentMax is hidden text box on PurchaseOrder Form
Me.txtGetCurrentMax = DMax("POnumber", "tblPurchaseOrders")

For iCount = 1 To NumberToPrint Step 1

Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("tblPurchaseOrders", dbOpenDynaset)

rs.AddNew
rs!PONumber = 1 + DMax("POnumber", "tblPurchaseOrders")
rs!Department = Me.cboDepartment.Column(0)
rs.Update
rs.Close

Set rs = Nothing
Set db = Nothing

Next

'now print the blank PO's (blank except for PO#s/Dept's)

Private Sub Command156_Click()
On Error GoTo Err_Command156_Click

Dim NumberToPrint As Long
Dim iCount As Long

'txtPrintNumber is the unbound text box for User's input
NumberToPrint = Me.txtPrintNumber

'txtGetCurrentMax is hidden text box on PurchaseOrder Form
Me.txtGetCurrentMax = DMax("POnumber", "tblPurchaseOrders")

For iCount = 1 To NumberToPrint Step 1

Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("tblPurchaseOrders", dbOpenDynaset)

rs.AddNew
rs!PONumber = 1 + DMax("POnumber", "tblPurchaseOrders")
rs!Department = Me.cboDepartment.Column(0)
rs.Update
rs.Close

Set rs = Nothing
Set db = Nothing

Next

'now print the blank PO's (blank except for PO#s/Dept's)

'this rpt's record source is query with POnumber's critiera
'being: > [txtGetCurrentMax] on the PO form.

DoCmd.OpenReport "rptPurchaseOrdersBlanks"

Exit_Command156_Click:
Exit Sub

Err_Command156_Click:
MsgBox Err.Description
Resume Exit_Command156_Click
End Sub


Anyone notice any glaring problems with this? Or offer suggestions on better
ways of doing this?

Thanks, Josh
 
J

Josh

test reply

Not sure I understand the reasoning behind dropping the auto number. As long as
records are not deleted, there should be no "skipped" autonumbers. Using DMax +1 will be
susceptible to the same skipping, as long as someone is allowed to delete POs.

Thanks for the reply. I personally don't see a problem in using autonumbers,
but Boss doesn't want any 'skips'. The purcharse order form's "can delete" is
set to No.
Also, does your question about printing "blank" POs involve PO numbering? If so, I
think your in for real problems...

Yes, it does print the PO numbers on them. I set a yes/no field to show that
this is a "pre-printed" PO, and will follow-up based on that. What other
problems do I need to lookout for?

I've cobbled together the code below, and it seems to work. This will not be a
multi-user environment (there will be 'requests' from multi-users, but not the
actual issueing of the POs) so I shouldn't have the problem of number being used
by someone else while in the middle of this procedure.

But I'm uncertain about a few things:
1. My Dim statements, I used Long, and they seem to work, but should I use
something else?
2.Error handling, I have the access wizard type error handling, but it seems
like there should be some additional error handling in the rs.addnew section.
But, with the Next statement, I'm confused as to where I would add any Resume
Next statements (if any) for error handling,
3. Error handling aside, there just seems to be something I'm missing, after the
Next statement, it seems like there should be something more there.


Private Sub Command156_Click()
On Error GoTo Err_Command156_Click

Dim NumberToPrint As Long
Dim iCount As Long

NumberToPrint = Me.txtPrintNumber

'txtGetCurrentMax is hidden text box on PurchaseOrder Form
Me.txtGetCurrentMax = DMax("POnumber", "tblPurchaseOrders")

For iCount = 1 To NumberToPrint Step 1

Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("tblPurchaseOrders", dbOpenDynaset)

rs.AddNew
rs!PONumber = 1 + DMax("POnumber", "tblPurchaseOrders")
rs!Department = Me.cboDepartment.Column(0)
rs.Update
rs.Close

Set rs = Nothing
Set db = Nothing

Next

'now print the blank PO's (blank except for PO#s/Dept's)

Private Sub Command156_Click()
On Error GoTo Err_Command156_Click

Dim NumberToPrint As Long
Dim iCount As Long

'txtPrintNumber is the unbound text box for User's input
NumberToPrint = Me.txtPrintNumber

'txtGetCurrentMax is hidden text box on PurchaseOrder Form
Me.txtGetCurrentMax = DMax("POnumber", "tblPurchaseOrders")

For iCount = 1 To NumberToPrint Step 1

Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("tblPurchaseOrders", dbOpenDynaset)

rs.AddNew
rs!PONumber = 1 + DMax("POnumber", "tblPurchaseOrders")
rs!Department = Me.cboDepartment.Column(0)
rs.Update
rs.Close

Set rs = Nothing
Set db = Nothing

Next

'now print the blank PO's (blank except for PO#s/Dept's)

'this rpt's record source is query with POnumber's critiera
'being: > [txtGetCurrentMax] on the PO form.

DoCmd.OpenReport "rptPurchaseOrdersBlanks"

Exit_Command156_Click:
Exit Sub

Err_Command156_Click:
MsgBox Err.Description
Resume Exit_Command156_Click
End Sub


Anyone notice any glaring problems with this? Or offer suggestions on better
ways of doing this?

Thanks, Josh
 
J

Josh

Switching back and forth between Agent 1.91 and Free Agent 3.0...got haywire
somewhere along the line, and made a couple of replies that evidently were'nt
replies to this thread, but started a new thread? Anyway, sorry about that.
1. Nothing "wrong" with Long, though Integer would probably suffice.

Changed to Integer
2. Not sure if that's needed. If what you have works, that should do it.
3. Re the Next... (not critical, but)
Declare all your Dims and Sets before the For/Next

I think the mistake I made (pasting the same text twice) in the original post
made it appear like there were extra Dim statements. But I have gone back and
made sure all Dims/Sets are before the For/Next.
Looks as though your closing and reopening the rs. on each iCount... try
this...
Set db = CurrentDb
Set rs = db.OpenRecordset("tblPurchaseOrders", dbOpenDynaset)
For iCount = 1 To NumberToPrint Step 1
rs.AddNew
rs!PONumber = 1 + DMax("POnumber", "tblPurchaseOrders")
rs!Department = Me.cboDepartment.Column(0)
rs.Update
Next iCount
Set rs = Nothing
Set db = Nothing

Yeah, I wondered about that. I did make the change you suggested. I also
added rs.close between Next iCount and the two Set = nothing statements, that is
necessary, right? Seems to work OK.
Since you're using the form's recordset, leave it that way. I'd use a dilaog form with
that could be run at any time, standalone.
BeginningPO = DMax(yada yada) + 1
NoOfBlankPOs = (user entry field)
EndingPO = BeginningPO + NoOfBlankPOs
cboDept = (a combo selection)
That way you could use...
For iCount = BeginningPO to EndingPO Step1
rs!PONumber = iCount '(avoiding the DMax aggreagate function)
and the report query could be filtered by...
Between Forms!frmDialog!BeginningPO and Forms!frmDialog!EndingPO

I see, I'll test that out.

Thanks, Josh
 
A

Al Campagna

Josh,
Do a Google group search in microsoft.public.access.forms under "Nothing and Close"
It's a good discussion of the differences between Close and = Nothing
 

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

Top