Record # to come up automatically with a new record

G

Guest

I have imported an excel spreadsheet into Access. My clients have record #'s
assigned to them. I have created a form that has a command button to go to a
new record so that I may enter a new client. The problem is that the record
# is blank. I would like to have access automatically bring up the next
record # for a new client. Any help on this would be appreciated.
 
G

Guest

Put a text box on your form, make the control source property the column in
your table, and make the default value property
=DMax("[Record_#]","MyTable")+1

-Dorian
 
G

Guest

Dorian:

I tried the information below to no available. I re-read my e-mail and I
think perhaps I didn't explain myself well.

I have imported information into access from another data base. Each
contributor has a record # assigned to them from the previous database. In
my access data base, I have created a form, with macros in which I want to
add a new contributor. My macro allows me to bring up a blank form to enter
a new contributor, but the record # is blank as well. I need this macro to
bring up a sequential record #, for example, my last contributor in the data
base is record #17633. I need the new record being entered to have record
#17634 assigned to it and so on for the following new contributor. Clear as
mud, right? Any help I can get on this I would appreciate. I'm guessing I
need an expresion for this.

mscertified said:
Put a text box on your form, make the control source property the column in
your table, and make the default value property
=DMax("[Record_#]","MyTable")+1

-Dorian

jktthunt said:
I have imported an excel spreadsheet into Access. My clients have record #'s
assigned to them. I have created a form that has a command button to go to a
new record so that I may enter a new client. The problem is that the record
# is blank. I would like to have access automatically bring up the next
record # for a new client. Any help on this would be appreciated.
 
J

John Vinson

Dorian:

I tried the information below to no available. I re-read my e-mail and I
think perhaps I didn't explain myself well.

I have imported information into access from another data base. Each
contributor has a record # assigned to them from the previous database. In
my access data base, I have created a form, with macros in which I want to
add a new contributor. My macro allows me to bring up a blank form to enter
a new contributor, but the record # is blank as well. I need this macro to
bring up a sequential record #, for example, my last contributor in the data
base is record #17633. I need the new record being entered to have record
#17634 assigned to it and so on for the following new contributor. Clear as
mud, right? Any help I can get on this I would appreciate. I'm guessing I
need an expresion for this.

Another approach which can work is to use the Form's BeforeInsert
event. Find the event in the form properties; click the ... icon by
it; invoke the Code Builder and write code like

Private Sub Form_BeforeInsert(Cancel as Integer)
Me!txtRecordNo = NZ(DMax("[RecordNo]", "[YourTableName]")) + 1
Me.Dirty = False
End Sub

using your own table and fieldnames.

John W. Vinson[MVP]
 

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