Adding a sequence number

J

Jacinda

Why doesn't this work:
Me.Box = Nz(DMax("[box]", "TShipTemp", "[order]=" & Me.Order), 0) + 1

(this is in my before insert event of my sub form)

I am trying to set up a shipping screen, so that everytime my shipper goes
to the next line it will add a box number , (box 1, box 2 etc)... but this
only returns 1 for every line. How do I get this to work? or should I be
using a different code?


-Jacinda
 
D

Dale Fye

Unless you actually have a field named "[box]", recommend you try the
following:

Me.Box = Nz(DMax("box", "TShipTemp", "[order]=" & Me.Order), 0) + 1
 
J

John W. Vinson

Why doesn't this work:
Me.Box = Nz(DMax("[box]", "TShipTemp", "[order]=" & Me.Order), 0) + 1

(this is in my before insert event of my sub form)

I am trying to set up a shipping screen, so that everytime my shipper goes
to the next line it will add a box number , (box 1, box 2 etc)... but this
only returns 1 for every line. How do I get this to work? or should I be
using a different code?


-Jacinda

Without knowing the structure of the table TShipTemp or its contents, it's
more than a bit hard to say! The expression looks ok with the following
assumptions:

- there is a table TShipTemp with fields Order and Box
- It contains zero to many different values of Box for each value of Order
- The code is called from the BeforeInsert event of a form which contains
textboxes named Box (bound to Box) and Order (bound to and displaying the
current order)
- The Order field is of Number datatype
- The records are being saved to disk
 

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