M
MrH via AccessMonster.com
I was looking at some code for validation.... like this....
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
If ctl.Tag = "*" And Trim(ctl & "") = "" Then
msg = "Data Required for '" & ctl.Name & "' field!" & nl & _
"You can't save this record until this data is provided!" & nl & _
"Enter the data and try again . . . "
Style = vbCritical + vbOKOnly
Title = "Required Data..."
MsgBox msg, Style, Title
ctl.SetFocus
Cancel = True
Exit For
End If
End If
Next
Now the problem is this displays the field name.... which to alot of users
might be confusing. For example...... The "First Name" field or "Last Name"
field on a form might display.... "txtFName" or txtLName" ........ If the
user sees this in a message box they might not really know what field is
required!
What I want to do is display the Caption.. somethin like "ctl.Caption" not
"ctl.name" but can't seem to find any syntax that works.
Anyone help?
Thanks
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
If ctl.Tag = "*" And Trim(ctl & "") = "" Then
msg = "Data Required for '" & ctl.Name & "' field!" & nl & _
"You can't save this record until this data is provided!" & nl & _
"Enter the data and try again . . . "
Style = vbCritical + vbOKOnly
Title = "Required Data..."
MsgBox msg, Style, Title
ctl.SetFocus
Cancel = True
Exit For
End If
End If
Next
Now the problem is this displays the field name.... which to alot of users
might be confusing. For example...... The "First Name" field or "Last Name"
field on a form might display.... "txtFName" or txtLName" ........ If the
user sees this in a message box they might not really know what field is
required!
What I want to do is display the Caption.. somethin like "ctl.Caption" not
"ctl.name" but can't seem to find any syntax that works.
Anyone help?
Thanks