HELP: Unable to clear values for control of type text in a userfor
If you give your controls names that depend on the type of control they are,
then you can test the name. I'm not sure if there's a "technically correct"
naming convention for the various types, but I name my textboxes with a "tbx"
prefix, followed by some word that tells me what data the control is used
for. i.e. tbxStudentName, tbxAddr1. Then your test would be:
For Each Ctrl in Me.Frame1.Controls
If Left(Ctrl.Name, 3) = "tbx" Then Ctrl.Value = ""
Next Ctrl
"sam" wrote:
Hi All,
I have textboxes and comboboxes located in Frame1 and I only want to clear
values in Textboxes when a user changes Student_Id field
Here is my code so far:
Private Sub StudentId_Change()
For Each ctl In Me.Frame1.Controls
If TypeOf ctl Is TextBox Then
ctl.Value = ""
End If
Next
End Sub
For some reason the values in textboxes are not cleared, I inserted break
points and found out that the control type of Textbox is not identified and
hence passes the If statement directly to End if
Thanks in advance
|