Custom counter

  • Thread starter Thread starter Jean
  • Start date Start date
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!
 
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.
 
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!


.
 
Back
Top