M
Mark A. Sam
Hello,
I set a function to the OnClick property of a command button:
=disableField()
The function looks like this:
******* Code Start ****
Public Sub disableField()
Dim ctl As Control
Set ctl = Form.ActiveControl
If (Form.Controls(Mid(ctl.Name, 8)).Enabled) = True Then
Form.Controls(Mid(ctl.Name, 8)).Enabled = False
Else
Form.Controls(Mid(ctl.Name, 8)).Enabled = True
End If
End Sub
******* Code End****
The function Enables or Disables a Textbox on the form. I get this error
message then I click the button:
The expression On Click you entered as the event property setting produced
the following error:
The expression you entered contains invalid syntax.
*The expression may not result in the name of a macro, the name of a
user-defined function, or [Event Procedure].
*There may have been an error evalutiing the function, event or macro.
The function works fine and stepping though it doesn't result in errors
until after the End Sub statement when the above appears.
If I call the function from the Event Procedure, it works smootly without
error.
I don't wish to open the event procedure for every button I am using this
on, when I can more easily select the bottons and enter the function name on
the OnClick property.
Thanks for any help.
God Bless,
Mark A. Sam
I set a function to the OnClick property of a command button:
=disableField()
The function looks like this:
******* Code Start ****
Public Sub disableField()
Dim ctl As Control
Set ctl = Form.ActiveControl
If (Form.Controls(Mid(ctl.Name, 8)).Enabled) = True Then
Form.Controls(Mid(ctl.Name, 8)).Enabled = False
Else
Form.Controls(Mid(ctl.Name, 8)).Enabled = True
End If
End Sub
******* Code End****
The function Enables or Disables a Textbox on the form. I get this error
message then I click the button:
The expression On Click you entered as the event property setting produced
the following error:
The expression you entered contains invalid syntax.
*The expression may not result in the name of a macro, the name of a
user-defined function, or [Event Procedure].
*There may have been an error evalutiing the function, event or macro.
The function works fine and stepping though it doesn't result in errors
until after the End Sub statement when the above appears.
If I call the function from the Event Procedure, it works smootly without
error.
I don't wish to open the event procedure for every button I am using this
on, when I can more easily select the bottons and enter the function name on
the OnClick property.
Thanks for any help.
God Bless,
Mark A. Sam