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!

Add 1 to last record ID

Status
Not open for further replies.

wdverner

Technical User
Mar 10, 2005
160
GB
hi all,
when i complete an input form, i want the form to reload with the primary key ProductID to be increased by 1.

ProductID is an integer field (Not AutoNumber due to reasons elsewhere).

What I want is when i complete input for record with ProductID= 1 and click on finish I want the form to reload with ProductID= 2 and so on.

What is the best way of achieving this?

Thanks guys,
 
If you only have one or two users this:
Code:
Private Sub Form_BeforeInsert(Cancel As Integer)
Me.ProductID = DMax("ProductID", "Table4") + 1
End Sub
May suit. Otherwise you may wish to look for MichaelRed's FAQ on why autonumber should not be used.
 
How are ya dverner . . .

Have a look at the [blue]DMax[/blue] aggregate function . . .

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top