POLine increment

G

Guest

Hi there

I think I am on the right lines here but am getting an error

I am trying to have a LineNo increment starting at 1 for each line on a PO sub form. The subform is based on a tblPOLines

With each new PO number the POLines for that PONUmber should start at 1 - this is why I am not using Autonumber

On the POLines sub form I have put in the BeforeInsert even

Me!LineNo =
Me!LineNo = DMax("LineNo", "tblPOLine") + 1

Two things I have a question about. It doesn't seem to restart at 0 for the next new PO. And it seems to have disabled the ability to type into a couple of the fields on the POLine form i.e. Qty and a cmb box for UOM - I can enter an item ok, but the other fields aren't updateable?
Any ideas
Or should I handle this differently

Thanks in advance
shawn
 
G

Graham R Seach

Sharon,

You need to search for the highest number for that specific PO, and if it
doesn't exists, make it 1.

Me!LineNo = Nz(DMax("[LineNo]", "tblPOLine", "[POID] = " & Me!POID), 0) + 1

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Sharon said:
Hi there,

I think I am on the right lines here but am getting an error.

I am trying to have a LineNo increment starting at 1 for each line on a PO
sub form. The subform is based on a tblPOLines.
With each new PO number the POLines for that PONUmber should start at 1 -
this is why I am not using Autonumber.
On the POLines sub form I have put in the BeforeInsert event

Me!LineNo = 0
Me!LineNo = DMax("LineNo", "tblPOLine") + 1

Two things I have a question about. It doesn't seem to restart at 0 for
the next new PO. And it seems to have disabled the ability to type into a
couple of the fields on the POLine form i.e. Qty and a cmb box for UOM - I
can enter an item ok, but the other fields aren't updateable?
 

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