How to set the default value to (previous value + 1)??

G

Guest

MS Access 2K, Windows XP
====================
Hi,

I have a text-box control on a form bound to a numeric field. I'd like to
make the default value of this field in a new record to be one more than the
value in the previous record. I already have an Autonumber field in the
table, but I need another field with a similar incrementing property, with
the option of over-riding the default value if needed. The reason is that
usually, the ID increments by one, but sometimes, there are missing IDs, and
in that case, the next ID will be x more than the previous record's ID, where
x > 1.

In the AfterUpdate event of the textbox, I have the following code:
===============================================
Me.SurveyID.DefaultValue = Me.SurveyID + 1
===============================================

This seems to be working fine for every other record. Meaning, that if I
enter the ID as '12' and click on the new record navigation button, the next
record's ID reads '13'. But, when I click on the new record navigation
button, the record ID reads '13' instead of '14'.

What am I doing wrong, and how can I correct it? I've a feeling that the
answer is something obvious, but currently elusive :)

Thanks for any help/pointers in the right direction.

-Amit
 
G

Guest

Figured it out. I put the same code in Form OnCurrent event, instead of
control's AfterUpdate event, and it seems to be working fine.

-Amit
 

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