Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto Line Numbering in a form...

Status
Not open for further replies.

dm1

IS-IT--Management
May 6, 2000
22
US
Hi, <br><br>I have a form (orders) with a sub form that allows the user to select products to include.&nbsp;&nbsp;The sub form uses (SELECT DISTINCTROW Order Details.*,...) as its query.&nbsp;&nbsp;What I'd like to is incrementally number each item/record as the user adds it to the list.&nbsp;&nbsp;In effect, line numbering...<br><br>At this stage any solution would be great.&nbsp;&nbsp;Ideally I'd like the field displaying the line number to also write that out to the order details table (not orders table), but even just displaying simple line numbering in the form with no write-out, updated after any items are added would be great.<br><br>Can anyone give me some pointers on how to achieve this please?<br><br>Thanks, Jon.
 
Use an Autonumber for the line number. Make sure that you have two key fields for your subforms underlying table.<br><br>EG: OrderDetailID - Autonumber - Primary Key<br>&nbsp;&nbsp;&nbsp;&nbsp;OrderID - Integer - Primary Key<br><br>But why display the line number? If a line is deleted then the lines will not be re-numbered, and it can look quite strange if you add more items after adding items to another order.<br><br>You don't need to update it yourself because as soon as a record is entered it will automatically update itself with the next number. I'd suggest not displaying the line numbers, otherwise users may get confused.
 
Ahdkaw, thanks for your reply.&nbsp;&nbsp;I don't think my original post was clear.&nbsp;&nbsp;I don't want to include the existing primary key number.&nbsp;&nbsp;What I want is a way of displaying a flexible number as a column which reflects the position of the record in the sub form.&nbsp;&nbsp;That way if a record is deleted the numbering re-adjusts to allow for it.&nbsp;&nbsp;I found an article in the MS tech base (Q210340) but the code doesn't seem to work, even in their nwind db.&nbsp;&nbsp;&nbsp;<br><br>So I'm still open to suggestions here... :)
 
DM1,
Did you find a viable solution to this problem?

Thanks. ---------------------
survane@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top