Custom AutoNumber

J

Jim

Hello,
I need some help trying to create a custom autonumber. I want to
start at 1 and increment by 1 but I want the number to be preceded by
INT-. So the first record would be INT-1 the next record INT-2.
Thanks for any help!
 
B

Bruce M. Thompson

I need some help trying to create a custom autonumber. I want to
start at 1 and increment by 1 but I want the number to be preceded by
INT-. So the first record would be INT-1 the next record INT-2.
Thanks for any help!

If the prefix will always be "INT-", then don't store it. Simply concatenate the
prefix to the autonumber field in a textbox wherever you need to display it. The
textbox's "Control Source" property would be:

="INT-" & [RecordID]

.... where "RecordID" is the name of your autonumber field.
 
J

John Vinson

Hello,
I need some help trying to create a custom autonumber. I want to
start at 1 and increment by 1 but I want the number to be preceded by
INT-. So the first record would be INT-1 the next record INT-2.
Thanks for any help!

If *every* value should have INT- displayed (and not any other text),
then it's by far the simplest not to store the INT- in the table at
all. Just use a Long Integer field and set its Format property to


"INT-#"

To increment the number, use a Form to enter your data (table
datasheets don't have any usable events); in its BeforeInsert event
put code like

Private Sub Form_BeforeInsert(Cancel as Integer)
Me!txtINT = NZ(DMax("[INT]", "yourtable")) + 1
End Sub

(assuming the field is named INT and is displayed in a textbox named
txtINT).
 

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