V
vb_Dumb
Is there a way to make the auto number have 6 digits like 000001,
000002 ect... any help would be cool
Thanks in advance, Dan
000002 ect... any help would be cool
Thanks in advance, Dan
vb_Dumb said:ya i found it duh properties format, format, 000000 duh
I have used the DMax before (by used I mean copied off a website) ButAs Jeff has said, Autonumbers are intended to be used for one purpose and
only one purpose, to provide a unique identifier for each record. Here's a
post I've archived from a gentleman named John Vinson, MVP, explaininghow
autonumbers work:
************************** Quote ************************************
When using Autonumber, do be aware that there will be gaps in the numbering -
any record that's deleted will leave a gap; hitting <Esc> after starting a
record will leave a gap; adding records using an Append query may leave a
gap, often a huge one; replicating the database will make your invoice
numbers random.
In short... it's best NOT to use Autonumbers for human consumption, and
particularly not for consumption by accountants and auditors. Invoice
sequences like 319, 321, 322, 385, 386, 221841246, -1083225152 make such
people get very nervous.
************************ End Quote ********************************
If you need something like a PO number or an account number, etc. that will
be consecutive, redefine the datatype of the field to Text and use a hack
like this for generating an auto-incrementing:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.NewRecord Then
If RecordsetClone.RecordCount = 0 Then
Me.AI_Number = "000001"
Else
Me.AI_Number = Format(DMax("Val([MyAI])", "YourTable") + 1, "000000")
End If
End If
End Sub
I have used the DMax before (by used I mean copied off a website) But
the problem I have is the first record will work and the second one i
add i get an error message saying that my table cannot be found i think
the problem is that i am trying to use a linked table that is on a
network because i am in a multi-user envirorment I think I need more
code or something but i know you shouldn't use an auto number but i
can't figure out how to do it so if you can figure out a way to give me
an static "auto" number that would be awesome Thanks for your help!
Dan
Yes I am using forms before update event, here is my code. should I have
the text box bound to the field on my table?
i need the info in my table
for my reports. Does it matter if the forms based on a query that's
based that a table? And what should be the data type of the field on the
table... sorry i have no idea what i am doing I've done simple forms but
no vb and now I am doing a quality database for a company for no money
and i am only a temp so anyway any help would greatly be appreciated
Private Sub Form_BeforeUpdate(Cancel As Integer) If Me.NewRecord Then
If RecordsetClone.RecordCount = 0 Then
Me.DMRnumbertxt = "000001"
Else
** Me.DMRnumbertxt = Format(DMax("Val([DMR_Number])", "ETP_Table")
+ 1, "000000")**
End If
End If
End Sub
(** Ends Here)
Thanks, Dan
Can u show me because your talking french to me vb is like trying to
dance in a full body cast to me...
Thanks Dan
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.