Default Values in Tables

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

Guest

Hi,

I am trying to build an expression in my tables that makes the default value
always one higher than the previous default value. Can someone help me? I
tried to use:

=Count([Tabletbl]![Field])+1

But that didn't work.

Please help
 
Hi UnderSeven,

Have you tried using an Autonumber field? This will do this for you.

Damian.
 
Under,
Do that default value on your input form. You shouldn't be entering data directly into
a table. Use a form (it can be a data sheet view).
If that field (numeric) were named ClientID, and your table named tblClients, you would
give ClientID a default value of...
=NZ(DMax("[ClientID]","tblClients")) + 1

Count will not work. If you delete any records, the count will then generate duplicate
ClientIDs.
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."
 
Have you tried using an Autonumber field? This will do this for you.

You have to be careful with the word 'previous' in a set-based
language (because a set has no inherent order): contiguous in
sequence, last inserted, last generated, most recent (time), etc. Once
you've plumped for 'sequence', is autonumber really the best means of
achieving this? e.g.

INSERT INTO Test (data_col) VALUES (1);
INSERT INTO Test (ID, data_col) VALUES (2147483647, 2);
INSERT INTO Test (data_col) VALUES (3);

What was the 'previous' ID number?

INSERT INTO Test (ID, data_col) VALUES (99, 4);
INSERT INTO Test (data_col) VALUES (5);

What was the 'previous' ID number?

Jamie.

--
 

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