BeforeUpdate not firing

L

Lars Brownies

To prevent corruption I'm working with an unbound field in my form. The
unbound field's afterupdate event puts the value in the underlying memofield
and saves it. The form's beforeInsert doesn't fire when I start on a blank
record and when the unboud field is the first field that is entered.

In the form's beforeInsert event I have code that enters some values in
different fields.

How can I fix this so when the user starts with the unbound field, that the
form's beforeInsert gets fired and the values get entered?

Thanks,

Lars
 
G

Graham Mandeno

Hi Lars

You could check to see if action is required and call BeforeInsert
"manually":

If Me.NewRecord and IsNull(Me.[some field that gets a value]) Then
Call Form_BeforeInsert(0)
End If

The next question is where to out this code?

If you can wait until txtUnboundMemo_AfterUpdate, then insert it there.

If you must have the fields populated before the user types into the field,
use txtUnboundMemo_GotFocus.

If you need to exactly mimic the BeforeInsert behaviour (execute on first
keypress) then use txtUnboundMemo_KeyPress.
 
L

Lars Brownies

Thanks Graham,
IsNull(Me.[some field that gets a value])

I can use the autonumber field for that.
If you need to exactly mimic the BeforeInsert behaviour (execute on first
keypress) then use txtUnboundMemo_KeyPress.

Good idea!


Graham Mandeno said:
Hi Lars

You could check to see if action is required and call BeforeInsert
"manually":

If Me.NewRecord and IsNull(Me.[some field that gets a value]) Then
Call Form_BeforeInsert(0)
End If

The next question is where to out this code?

If you can wait until txtUnboundMemo_AfterUpdate, then insert it there.

If you must have the fields populated before the user types into the
field, use txtUnboundMemo_GotFocus.

If you need to exactly mimic the BeforeInsert behaviour (execute on first
keypress) then use txtUnboundMemo_KeyPress.

--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand


Lars Brownies said:
To prevent corruption I'm working with an unbound field in my form. The
unbound field's afterupdate event puts the value in the underlying
memofield and saves it. The form's beforeInsert doesn't fire when I start
on a blank record and when the unboud field is the first field that is
entered.

In the form's beforeInsert event I have code that enters some values in
different fields.

How can I fix this so when the user starts with the unbound field, that
the form's beforeInsert gets fired and the values get entered?

Thanks,

Lars
 
R

Rick Brandt

To prevent corruption I'm working with an unbound field in my form. The
unbound field's afterupdate event puts the value in the underlying
memofield and saves it. The form's beforeInsert doesn't fire when I
start on a blank record and when the unboud field is the first field
that is entered.

In the form's beforeInsert event I have code that enters some values in
different fields.

How can I fix this so when the user starts with the unbound field, that
the form's beforeInsert gets fired and the values get entered?

BeforeInsert is not guaranteed to fire. That's the reason I never use it.
 

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