I have a form that has nothing but unbound text boxes on it.
Data is entered via a textbox that performs a dlookup function on an afterupdate event.
I have been looking at all the examples showing how to clear the txtboxes at once, but I cannot get any of them to work. I keep getting error messages... I do not want to create a line of code for each textbox to clear (like the example below). I have alot of controls on the form.
Is there a way to loop thru all the controls on the form and clear (or make the value null) all at once?? Below is an example of what I am working with. This works fine but like I said, I have alot of unbound txtboxes on the form. This code also changes the color of the labels forecolor, backcolor and bordercolor. Any other example coding would be most appreciated!!
Thanks, jw5107
For Each ctrl In Forms (strWWReviewHelper).Controls
If TypeOf ctrl Is TextBox Then
Forms![WWReviewHelper]![USAGE] = Null
Forms![WWReviewHelper]![PRIME] = Null
Forms![WWReviewHelper]![Text508] = Null
End If
If TypeOf ctrl Is Label Then
ctrl.ForeColor = vbBlack
End If
If TypeOf ctrl Is Label Then
ctrl.BackColor = 16777215
End If
If TypeOf ctrl Is Label Then
ctrl.BorderColor = 16777215
End If
Next ctrl
Data is entered via a textbox that performs a dlookup function on an afterupdate event.
I have been looking at all the examples showing how to clear the txtboxes at once, but I cannot get any of them to work. I keep getting error messages... I do not want to create a line of code for each textbox to clear (like the example below). I have alot of controls on the form.
Is there a way to loop thru all the controls on the form and clear (or make the value null) all at once?? Below is an example of what I am working with. This works fine but like I said, I have alot of unbound txtboxes on the form. This code also changes the color of the labels forecolor, backcolor and bordercolor. Any other example coding would be most appreciated!!
Thanks, jw5107
For Each ctrl In Forms (strWWReviewHelper).Controls
If TypeOf ctrl Is TextBox Then
Forms![WWReviewHelper]![USAGE] = Null
Forms![WWReviewHelper]![PRIME] = Null
Forms![WWReviewHelper]![Text508] = Null
End If
If TypeOf ctrl Is Label Then
ctrl.ForeColor = vbBlack
End If
If TypeOf ctrl Is Label Then
ctrl.BackColor = 16777215
End If
If TypeOf ctrl Is Label Then
ctrl.BorderColor = 16777215
End If
Next ctrl