Default value

  • Thread starter Thread starter Scott
  • Start date Start date
S

Scott

I use after update event procedure in a field of form and it works fine.
However, once I put a default value, i.e., Date(), the after update event
procedure does not work at all. Can someone advise what are the differences
between no default value and default value and how to resolve it if default
value is needed.

Thanks,

Scott
 
when you set the DefaultValue property of a field in a table, or bound
control in a form, the value is assigned programmatically - therefore the
control's AfterUpdate event does not run.

what action are you taking on the AfterUpdate event of the control? can you
run it at some other point in the form?

hth
 
Tina,

Thanks for your explanation.

The action is taken to select the records based on the default value or
other value entered and get the highest value of other field amongst records
then automatically fill in other field. Is there any other event procedure
to fit for this purpose?

Thanks,

Scott
 
sorry, i didn't really follow that at all. you could run your code from a
command button, i suppose. if that doesn't suit your needs, please post a
"real-world" example what the code is supposed to do (and the code itself,
too), so i can get a better picture.

hth
 
Tina,

Thanks for your reply. Below is the event procedure used in the field.
Using a command button should be ok if no other way.

Private Sub txtDatefield_AfterUpdate()
Me.txtIncrement = Nz(DMax("[Increment]", "tblReport", "Year([Datefield]) = "
& Year(Me.txtDatefield)), 0) + 1
End Sub

Scott
 
well, if txtIncrement is a bound control, and if your user does not need to
see the incremented value, then you could use the form's BeforeUpdate
event - that's assuming that you are editing data in at least one other
control on the form.

hth


Scott said:
Tina,

Thanks for your reply. Below is the event procedure used in the field.
Using a command button should be ok if no other way.

Private Sub txtDatefield_AfterUpdate()
Me.txtIncrement = Nz(DMax("[Increment]", "tblReport", "Year([Datefield]) = "
& Year(Me.txtDatefield)), 0) + 1
End Sub

Scott

tina said:
sorry, i didn't really follow that at all. you could run your code from a
command button, i suppose. if that doesn't suit your needs, please post a
"real-world" example what the code is supposed to do (and the code itself,
too), so i can get a better picture.

hth
 
Back
Top