sequential numbering - form

N

Number46

I am new to Access. I have just built a basic database and I have
everything functioning (forms and reports) but this one thing. I am not very
good with writing code.

I would like to be able to incorporate a unique incident number that will be
automatically created and then stored in the table when the user opens the
form(without a user needing to click on a button or manually enter anything),
but I cannot seem to figure it out the best way to accomplish this It
doesn't matter if one of the records is eventually deleted, as the number
will be tied to the incident and will not be re-used. It just needs to be
unique and not a duplicate number.

I have been unsuccessful in my search for answers. I have attempted to
increment by 1 from a number field in the previous record using the Dmax
function, but was not having much success.

Could someone please point me in the right directon or offer any advice on
how to I accomplish my goal (if it is possible).

Thanks in advance!
 
S

Scott Lichtenberg

The easiest way is to set the field type to Autonumber in table design.
Access will then assign a new (and unique) id number to every record in your
table as it is created. You don't have to do anything. One quick note: the
autonumber is assigned as soon as the user starts adding data in the record.
 
N

Number46

I already have the PK set to Autonumber. I was under the false assumption
that it wasn't a good thing to use this field for anything other than that
purpose.

Since that is what everyone I have asked is telling me to use, then I guess
I will work with that.

Since I want to show an "IR-" in front of the number on my form and when I
print out the record, I am just going to add a column with the following in a
query and put that onto my form.

IncidentNo: "IR-" & "" & [ID]

Thanks!
 

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