Hi all,
I am trying to make a function that clears all values in text boxes on a form (a basic 'undo' option). Several textboxes and comboboxes are on different tabs. However, when I call the function and run the function nothing on the form changes... is there something wrong with the code below? Do I need to reference the controls on the tabs differently?
Thanks,
jbehrne
If at first you don't succeed, call in an airstrike. - Murphy's Laws of Combat Operations
I am trying to make a function that clears all values in text boxes on a form (a basic 'undo' option). Several textboxes and comboboxes are on different tabs. However, when I call the function and run the function nothing on the form changes... is there something wrong with the code below? Do I need to reference the controls on the tabs differently?
Code:
Private Function UndoForm() As Boolean
UndoForm = True
Dim ctl As Control
Try
For Each ctl In Me.Controls
If (TypeOf ctl Is TextBox) Or (TypeOf ctl Is ComboBox) Then
ctl.Text = ""
End If
Next
Catch ex As Exception
UndoForm = False
Exit Function
End Try
MsgBox("Finished.")
End Function
Thanks,
jbehrne
If at first you don't succeed, call in an airstrike. - Murphy's Laws of Combat Operations