can i automatically increase a field that uses text and numbers

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a primary key field that I would like to automatically increase.
Example: when a user adds a new record on a form, I would like the field to
automatically populate like an auto number. i.e. TER-002, TER-003, TER-004
etc. Can this be done?
 
If you want it to be "just like an AutoNumber," then use an AutoNumber. In
the text box that displays this AutoNumber field on the form, place the
following syntax in the Control Source Property of the text box:

="TER-" & Format([ID],"000")

.. . . where ID is the name of the field and txtID is the name of the text
box control, because these names _can't_ be identical. When you use an
AutoNumber, bear in mind that gaps can get in, so these numbers aren't
guaranteed to be sequential.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
Djembe78 said:
I have a primary key field that I would like to automatically increase.
Example: when a user adds a new record on a form, I would like the
field to automatically populate like an auto number. i.e. TER-002,
TER-003, TER-004 etc. Can this be done?

I suggest you may not want to use Autonumber for that use. Autonumbers are
designed to provide unique numbers. It in not designed to provide numbers
in order and for a number of reasons may not do so. As a result using them
in any application where the user sees the numbers is likely to end up with
confusion.

There are other ways of providing the numbers you want depending on the
particual application.

As for the text part, if it is always the same, you don't put it in the
field at all, you add it as needed for display.
 

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

Back
Top