Field Doesn't Save to Table (1 Viewer)

brsawvel

Registered User.
Local time
Yesterday, 20:46
Joined
Sep 19, 2007
Messages
256
I have an On Open event for my form that says Me.fldX DMAX("[fldX]", "tblX") + 1.

fldX appears fine (it adds one to the highest number in that column and places the result into fldX), but when I enter values in the remaining fields and close the form, fldX show a value of 0 in tblX.

Any idea what I'm doing wrong? I'm doing it this way, because I want to add another button later on that gives the user the option of keeping fldX value the same rather than doing +1 again.
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 18:46
Joined
Aug 30, 2003
Messages
36,139
Is the textbox bound to the field in the table (the control source property)?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 20:46
Joined
Feb 28, 2001
Messages
27,425
The question is whether [fldX] is bound properly. Also, are you saying that the contents of the property slot for the OnOpen event contains a formula?

Also, this is a very narrowly directed fine point, but I don't recall that all of the fields are available on the OnOpen event. Some things (if they are bound) are not available until the OnLoad event which immediately follows the OnOpen event, because the recordset might not yet be open.

I can imagine a mechanism to explain this situation by saying that the field MIGHT be updated by your formula in OnOpen, but then might get overwritten by OnLoad or OnCurrent, both of which fire after OnOpen.

The question is not the value of [fldX] after OnOpen fires but rather, what is its value before the BeforeUpdate fires. Have you tested that?
 

brsawvel

Registered User.
Local time
Yesterday, 20:46
Joined
Sep 19, 2007
Messages
256
Thank you Gents! Apologies it took me a bit to respond, but I finally got back to working the DB and your recommendations worked.
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 18:46
Joined
Aug 30, 2003
Messages
36,139
Glad you got it working.
 

Users who are viewing this thread

Top Bottom