|
Home > Archive > MS Access database support > April 2006 > Microsoft's choice to default form textbox names to related table field names - good or bad?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Microsoft's choice to default form textbox names to related table field names - good or bad?
|
|
|
| Generally, I do not monkey with renaming controls on forms
whose name, by default, matches the name of their related
table fields. But I noticed the following today
If IsNull(Me!VColor) Then
DoCmd.CancelEvent
SaveButtonClicked = False
MyString = "You must tell us the color of the vehicle."
MyString = MyString & "Please choose the vehicle color from "
MyString = MyString & "the drop-down box provided on form."
MsgBox MyString, vbExclamation, "Vehicle Color Required - "
Exit Sub
End If
This code has been in my app for 9-mos. "What's the point", you ask?
The point is this: The control's name is NOT VColor. Its a combo-box
control and its name is ColorChooserBox. The related table field name
is [VColor].
A line in there like this
Me!VColor.BackColor = 255
would-a-produced an error. I would-a-seen & fixed it.
But because Null is a perfectly acceptable value for the table field
value - I got no error. I would have appreciated one, however. The
result of this SNAFU is not monumental really. Because either of the
following in the immediate window yield the same result:
? forms!frmVehicleEntr
yForm!VColor
Azure
? forms!frmVehicleEntr
yForm!ColorChooserBo
x
Azure
But how do I knoiw that I won't be so lucky in another situation
that's similar - but slightly different. Is it possible, in A97, for
Access to use a different naming convention for controls on forms?
I would-a-been happier, I think, if Microsoft had defaulted names to
something like ctlVColor or comboxVColor or cboxVColor. I think I
would-a-been happier with cbox1, cbox2, cbox3... like they do with
command buttons.
| |
|
| <snip>
>I didn't follow what you were trying to say in the rest of your post,
>MLH, but the above definitely caught my eye.
>
>I personally make it a habit to definitely rename bound controls to a
>standard naming convention. Otherwise you end up with a lot of #Name!
>type errors when trying to perform actions or procedures on controls. I
>always advise newbies to do the same and tell them it's never good
>practice to do what you describe above unless there is no coding
>whatsoever connected with the form/report.
I tend to agree with you. Would be nice if we could set a low-level
option specifying our desired control naming convention to A97.
|
|
|
|
|