Some of it is personal preference. Using Me makes it a little more apparent
when reading the code that it is an item on the form/report, not just a
variable. This would be similar to putting "int" on the front of an integer
variable (i.e. intMyVariable). It will also sometimes remove problems if you
have duplicate names because it pins down which item you are referring to;
however, it is better to remove the duplicate names.
As far as placing the equation in the control source, if you do that you now
have a calculated control that the user can't type information into. If
that's what you're after, then that's probably the better way. If you want
the control to be a bound control and you want to change it programmatically
also, then you can't put the equation in the control source. By the way, I
don't know if you just did this for the message or not, but if it is put in
the control source, the name of the control on the left side of the equal
sign isn't entered, it automatically refers to the control whose control
source it is in.
Example:
CExt1 = Nz([CDoz1], 0) * Nz([CPrice1], 0)
Change the above to
= Nz([CDoz1], 0) * Nz([CPrice1], 0)
When placing it in the control source of the control CExt1. Also, Me won't
be recognized here.
--
Wayne Morgan
Microsoft Access MVP
"JC Mugs" <jc****@hotmail.com> wrote in message
news:10*************@corp.supernews.com... I am having a conceptual problem.
When working with a forms & Code sections which is correct method and how
do they differ when working with fields?
Code
Private Sub CExt1_BeforeUpdate(Cancel As Integer)
Me!CExt1 = Nz([CDoz1], 0) * Nz([CPrice1], 0) ; this one?
CExt1 = Nz([CDoz1], 0) * Nz([CPrice1], 0) : Or this?
End Sub
Form Control Source
CExt1 = Nz([CDoz1], 0) * Nz([CPrice1], 0) Or is this correct
way to do it?
My problem is when do you use the Me! with a field and when is it not
needed. Or just what the heck is the concept behind them...
Thanks,
JC