cmdRESET_Click()

  • Thread starter Thread starter Doug Vernon
  • Start date Start date
D

Doug Vernon

I tried to use the following code to clear the text boxes
(controls) on a custom dialog box:
********************
Private Sub cmdReset_Click()
On Error GoTo ResetError
Dim Frm As Form, Ctl As Control

Set Frm = Me
For Each Ctl In Frm
Ctl.Value = Null
Next Ctl

ResetError:
If Err = 2119 Or Err = 438 Or Err = 2448 Then
Resume Next
ElseIf Err > 0 Then
MsgBox Err & ": " & Err.Description
End If
End Sub
********************

When I try to debug/compile the code, I get an error
message that says "Compile Error: Invalid use of Me
Keyword".

Any help would be appreciated. dv
 
Doug,

Did you put this in the form's module or into a general module? It would
need to be in the module of the form itself in order to recoginize 'Me'.
Otherwise you will have to pass the name of the form to the code in the
general module.

It is looking like you are using the Sub name from the code that I gave you.
You would want to put this code into the OnClick event of your command
button. This event will supply its own name depending on how you have named
the button. You would then want to just insert the code between the "Private
Sub" and the "End Sub" in my example.

Gary Miller
 
Back
Top