D
Donna Rae
In a form, can a field be made non-editable AFTER it has been filled in by an
event procedure?
event procedure?
Klatuu said:Also, are you naming your controls the same as the
recordset fields? Although allowed, it is not a good idea. It can
be confusing for a human to know which object you are addressing and
in some cases, it can confuse Access.
Dirk Goldgar said:In
Just in the interest of friendly debate, I'll challenge this statement. In
the context of control names, I don't think it's harmful and I have never
seen Access get confused. Can you provide an example to support your
assertion?
I just did this for a few fields in one of my new forms. Put this codeJeff,
What I have is a form with several fields that get automatically populated
through an event procedure. What I want to do is after those fields are
populated to not allow the user to change any of the data in those fields.
If I lock the field with the Locking property, then it will not populate the
field when the user begins to use the form.
Thanks for your quick reply.
Douglas J. Steele said:If your control is named the same as the field in its control source,
you'll run into problems. For example, if you've got a field named
CustomerName, your control is named CustomerName and its
ControlSource is =[CustomerName] & IIf([Active], "", " (Inactive)")
Yeah, I know it's a contrived example, but if you started out with the
recordset field being the ControlSource and then decided to change
it, you can run into that situation.
Dirk Goldgar said:InDouglas J. Steele said:If your control is named the same as the field in its control source,
you'll run into problems. For example, if you've got a field named
CustomerName, your control is named CustomerName and its
ControlSource is =[CustomerName] & IIf([Active], "", " (Inactive)")
But that's not at all the same as a control with the same name as its
controlsource. That's a calculated field that creates a circular
definition. The controlsource '=[CustomerName] & IIf([Active], "", "
(Inactive)")' is obviously not the same as 'CustomerName'.
Can anyone provide a case where the simple fact that a control is named
the same as its controlsource has confused Access or cause it to fail?
Yeah, I know it's a contrived example, but if you started out with the
recordset field being the ControlSource and then decided to change
it, you can run into that situation.
Sure, but it's not a case of *Access* being confused -- it's the
*programmer* who was confused. So which is more cumbersome, renaming
all your controls so that they don't share the names of their bound
fields, or remembering to change the names of calculated controls on
those occasions when you create them from bound controls?
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
Klatuu said:Yes, Dirk, I can. I was asked to work an an app where a field in the
recordset was named Date and the bound control was named Date. It
had in the code something like If Date > Date() Then
It returned unreliable results. I enclosed the reference in brackets
so it became
If [Date] > Date() and still got bad results. To get it to return the
correct results I had to code it as If [Date] > vba.Date.
Dirk Goldgar said:InKlatuu said:Yes, Dirk, I can. I was asked to work an an app where a field in the
recordset was named Date and the bound control was named Date. It
had in the code something like If Date > Date() Then
It returned unreliable results. I enclosed the reference in brackets
so it became
If [Date] > Date() and still got bad results. To get it to return the
correct results I had to code it as If [Date] > vba.Date.
Neat example! BUT ... the problem there wasn't because the control was
named the same as the field, but because both were named the same as the
function.
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
Klatuu said:Can you validate that?
You may be correct; but, The point is that the developer using a
reserved word caused the problem. So, my point stands that using
reserved words can be problematic.
Good naming conventions make it
easy for even us human types to understand what is being done.
Klatuu said:For example, had the OP used the very common txtDate, the
problem would not have happened.