table doesn't update until after I press the escape key

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

Guest

I have a form with subform working but with one issue - when I enter data
into a row I start on the next row, but get error about duplicate key. I
press the escape key, it clears the data I just tried inputing, and it
updates the key field. The key field causing the error uses this in the
default value property field-

=Nz(DMax("SongID","MusicOnPC_Songs"),0)+1

Is there something missing to make it update after I tab out of the last
field for that row, and move into the next row?
 
try removing the expression from the DefaultValue property of the SongID
field. instead, run the following code from the subform's BeforeUpdate
property, as

Me!SongID = Nz(DMax("SongID","MusicOnPC_Songs"),0)+1

if SongID is the primary key field of table MusicOnPC_Songs, it might be
easier to just set the field's data type as Autonumber and let Access do the
work instead.

hth
 

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