Office & Productivity Software forum

General discussion

MS Access

by Berfert / April 6, 2005 12:32 AM PDT

I have a database for tracking new/old requirements for systems development. In the past these were tracked via notepad, excel, word by a number of people and our requirement numbers varied and was very confusing for our developers. What I did was create a access DB with one of the fields labeled requirement number and in this field I'm listing all of the old requirements using whatever number they originally had. Now going forward when adding a new requirement I want this number to auto-populate with the next higher number, last record + 1 kind of thing. I can't use auto-number with the existing field and I don?t want a new field with auto-number because it would start at #1 all over again.

The question is how can I make the default value of my field be last record number + 1?

Discussion is locked
You are posting a reply to: MS Access
The posting of advertisements, profanity, or personal attacks is prohibited. Please refer to our CNET Forums policies for details. All submitted content is subject to our Terms of Use.
Track this discussion and email me when there are updates

If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.

You are reporting the following post: MS Access
This post has been flagged and will be reviewed by our staff. Thank you for helping us maintain CNET's great community.
Sorry, there was a problem flagging this post. Please try again now or at a later time.
If you believe this post is offensive or violates the CNET Forums' Usage policies, you can report it below (this will not automatically remove the post). Once reported, our moderators will be notified and the post will be reviewed.
Collapse -
Potholes in the design.
by R. Proffitt Forum moderator / April 6, 2005 12:50 AM PDT
In reply to: MS Access

One of the interesting things you learn is never to use the record number for anything useful. It can change over time and upset the maintainer of the database.

Instead, make the field requirement be "unique" to disallow duplicates. You can prefill it with a command of recno()+1 with a command (your work) to get it started and add code to find the max number of the existing records and add 1 when you add a new record.

Bob

Collapse -
Re: autonumber
by Kees Bakker / April 6, 2005 6:00 AM PDT
In reply to: MS Access

In this case (but it depends on the requirements indeed) you could consider to use the autonumber feature, because it's a really meaningless number.

I think you can start with defining it as long integer while you add the old records. Then use the SQL ALTER TABLE statement explained in http://support.microsoft.com/?scid=kb;en-us;884185&spid=2509&sid=global, either from the query definition screen or from VBA to change the field to autonumber with the correct start value (=seed) and increment (1).

It saves you some coding to put under the OK- (or Add) button in the screen you've made. But it's not very difficult either, of course, to fill a field with the value dmax(...)+1.

Hope this helps.


Kees

Popular Forums
icon
Computer Newbies 10,686 discussions
icon
Computer Help 54,365 discussions
icon
Laptops 21,181 discussions
icon
Networking & Wireless 16,313 discussions
icon
Phones 17,137 discussions
icon
Security 31,287 discussions
icon
TVs & Home Theaters 22,101 discussions
icon
Windows 7 8,164 discussions
icon
Windows 10 2,657 discussions

Does BMW or Volvo do it best?

Pint-size luxury and funky style

Shopping for a new car this weekend? See how the BMW X2 stacks up against the Volvo XC40 in our side-by-side comparison.