![]() |
|
#1
|
|||
|
|||
|
I have two types of controls on my form: textboxes and combo boxes. My text boxes are all named in the format txt1, txt2, txt3...... Combo boxes are cbo1, cbo2, cbo3....
I have a button on the form that clears all values from both controls. The button is named cmdClear. The code is: Code:
Private Sub cmdClear_Click()
Dim cControl As Control
For Each cControl In Me.Controls
If cControl.Name Like "txt*" Or cControl.Name Like "cbo*" Then cControl = vbNullString
Next
End Sub
Code:
Private Sub cmdClear_Click()
Dim cControl As Control
For Each cControl In Me.Controls
If cControl.Name Like "*" Then cControl = vbNullString
Next
End Sub
"Run time error '5" Invalid Procedure Call or Argument Why am I getting this error? I even tried: Code:
Private Sub cmdClear_Click()
Dim cControl As Control
For Each cControl In Me.Controls
cControl = vbNullString
Next
End Sub
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Word Form to Save as and clear
|
sfitzsimmons | Word VBA | 1 | 01-11-2019 02:03 PM |
Don't clear form fields when protecting as a form
|
BruceM | Word | 5 | 10-06-2016 08:26 AM |
| Form with content controls - expands but at the bottom of the form | louiseword | Word | 3 | 05-27-2016 12:47 AM |
Retrieve Values from Content Controls for hidden
|
john s. | Word VBA | 1 | 02-21-2014 02:14 PM |
| Calculations using values from date picker controls | Inkarnate | Word | 0 | 06-09-2010 07:16 AM |