A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

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



 
 
Thread Tools Display Modes
  #1  
Old October 28th, 2007, 04:47 AM posted to microsoft.public.access.forms
Chip
external usenet poster
 
Posts: 147
Default table doesn't update until after I press the escape key

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?
  #2  
Old October 28th, 2007, 12:56 PM posted to microsoft.public.access.forms
tina
external usenet poster
 
Posts: 1,997
Default table doesn't update until after I press the escape key

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


"Chip" wrote in message
...
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?



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:10 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.