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

Autonumber Prefix

Status
Not open for further replies.

BobChesh

Technical User
Dec 13, 2001
39
GB
How can I prefix an autonumber with a bit of text?

I want to add records, using the Autonumber as the ID, but I want to prefix the value with "BUS ", so the record ID becomes BUS 1, BUS 2 etc etc.

cheers
 
Don't think you can, unless you use two fields and concatenate them. I would not use Autonumber for this anyway. Best to write code to establish last number used and increment it, then make it a string and add the 'BUS ' part in code as well. Have fun! :eek:)

Alex Middleton
 
Or even better, just concatenate on "BUS" on the form....

Craig
 
Craig,

Trieed this (I think), and it works, until I get to double figures, i.e. .... BUS 7, BUS 8, BUS 9, 1BUS 0, 1BUS 1....

or am I putting the concantenation in the wrong bit of the properties of the form. Give me a clue!!

Thank you for your reply, and hope you can do this last bit for me.

Cheers

Bob
 
Set the ControlSource on the control to ="BUS" & [YourFieldName]

Craig
 
Just a question. Is it crucial that the autonumber part is always consecutive, i.e. no gaps in the sequence. If so then don't use autonumber - it will put gaps in in certain situations and it is a pain to get it to always do what you want.

If this is not an issue, however, then autonumber is the easy way to do it. Have fun! :eek:)

Alex Middleton
 
Criag,

Thats what I thought, but all I get is the error "#Name?"

Give up or what??


Bob
 
#Name? means that the control can't find the data from the recordset. Check the ControlSource property of your control(s) and/or the RecordSource property of the form to make sure it is getting access to the data. Also, is the form set to input a new record, e.g. AllowAdditions = True, DataEntry = True? Any of these could lead to this error. Have fun! :eek:)

Alex Middleton
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top