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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to Increment Last Record by 1 on Form 1

Status
Not open for further replies.

JohnTcolo

MIS
Aug 28, 2002
216
US
We are tracking invoices. Can't use auto-number because users will be entering different batchs. I don't want them to have to input the number each time, but they DO need to be able to change it on occasion.

I can't get the code to work, can someone please give me the code? I know it is simple, but I don't work with Access that much.

Thanks in advance.
 
Hi :)

On Current Event of Form write this

Din intMax as Integer

If Me.NewRecord=True

intMax=Dlookup("Max(IDNo)","MyTable")
intMax=intMax+1
Me.IDNo=intMax

End If

Where IDNo is your primary key which you want to increment.

Hope it helps.

Cheers!
Aqif
 
Post the code you have implemented which is not working the way you want it to work and someone will help you resolve the remaining issues. Robert Berman
Data Base consultant
Vulcan Software Services
thornmastr@yahoo.com
 
Will post my erroneous code as soon as I get back to the office in the a.m. Thanks for the quick responses.
 
I am somewhat confused on Currentevent. Here is what the code looks like from my form:

Private Sub Tktnum_BeforeUpdate(Cancel As Integer)

===========================================================
Private Sub Tktnum_BeforeUpdate(Cancel As Integer)


intMax = DLookup("Max(tktnum)", "tickets")
intMax = intMax + 1
Me.IDNo = intMax

End Sub
===========================================================

Thanks in advance for your help!
 
The current event fires immediately when a new record is brought into the form. Technically there is nothing wrong with your code.

If intmax is defined as autonumber, you cannot change or modify it. If that is the case, make it a long number.
Robert Berman
Data Base consultant
Vulcan Software Services
thornmastr@yahoo.com
 
No, I am not using autonumber, it already is a long number. Thanks.
 
Ooops, never mind I see what I did wrong. (idno is NOT the field!!!) Time for some more coffee. Thanks folks for the quick responses.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top