Custom counter

J

Jean

Hello,

I'm looking for a few tips as an inexperienced access
database programmer.

I have a table that contains field such as PersonNumber
(primary key), Surname and Name. The field type for person
number is Long Integer.
Then, I have a form, with which I want to add a new record
to this table, without using Access's New. navigation
button. I want the next available PersonNumber to appear
on the form in a TextBox say txtPersonNumber. Then text
boxes for the person' name are blank and provided for user
input, and once OK is hit, a new record must be created
and added to the table.
What is an efficient way of doing this? Must I write code
that looks at the last value of PersonNumber in the table,
and then add 1 to that number?
I know that there is the Autonumber field type, but I do
not want to use this. J
Please help!

Thanks in advance!
 
P

PC Datasheet

Open your form in design view and open properties. Go to the Data tab and set
Data Entry to Yes. Any time your form opens, it will now open to a new record.

While your form is in design view, select the PersonNumber textbox. Go to the
Data tab in properties and enter the following expression for the default
property:
DMax("[PersonNumber]","NameOfYourTable") + 1
When you now enter anything into any other field on your form, the PersonNumber
field will automatically fill with the next PersonNumber.
 
J

Jean

Thanks!
-----Original Message-----
Open your form in design view and open properties. Go to the Data tab and set
Data Entry to Yes. Any time your form opens, it will now open to a new record.

While your form is in design view, select the
PersonNumber textbox. Go to the
Data tab in properties and enter the following expression for the default
property:
DMax("[PersonNumber]","NameOfYourTable") + 1
When you now enter anything into any other field on your form, the PersonNumber
field will automatically fill with the next PersonNumber.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com


Hello,

I'm looking for a few tips as an inexperienced access
database programmer.

I have a table that contains field such as PersonNumber
(primary key), Surname and Name. The field type for person
number is Long Integer.
Then, I have a form, with which I want to add a new record
to this table, without using Access's New. navigation
button. I want the next available PersonNumber to appear
on the form in a TextBox say txtPersonNumber. Then text
boxes for the person' name are blank and provided for user
input, and once OK is hit, a new record must be created
and added to the table.
What is an efficient way of doing this? Must I write code
that looks at the last value of PersonNumber in the table,
and then add 1 to that number?
I know that there is the Autonumber field type, but I do
not want to use this. J
Please help!

Thanks in advance!


.
 

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