Hi!
I was given some help on a previous thread to cycle through some controls on a form to enable/disable them, which worked great. However, I now need to move this from the form procedure level to part of a function, but seem to be running into diffuculties. The code is below:
Dim ctl As Control
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acComboBox, acListBox, acTextBox, acCheckBox
If (ctl.Name <> "txtTst") Then
ctl.Enabled = Not ctl.Enabled
ctl.Locked = Not ctl.Locked
'toggling the property
End If
End Select
Next ctl
Basically, I don't think it likes the 'Me' part as it can't reference it. When I call the function from the form, I already send the form name by using: var_ReturnValue = bas_Edit(Me). I have tried using this in the function and replacing Me.Controls with FrmName.Controls but this doesn't work either.
Any ideas? I'm sure it's really simple!?
I was given some help on a previous thread to cycle through some controls on a form to enable/disable them, which worked great. However, I now need to move this from the form procedure level to part of a function, but seem to be running into diffuculties. The code is below:
Dim ctl As Control
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acComboBox, acListBox, acTextBox, acCheckBox
If (ctl.Name <> "txtTst") Then
ctl.Enabled = Not ctl.Enabled
ctl.Locked = Not ctl.Locked
'toggling the property
End If
End Select
Next ctl
Basically, I don't think it likes the 'Me' part as it can't reference it. When I call the function from the form, I already send the form name by using: var_ReturnValue = bas_Edit(Me). I have tried using this in the function and replacing Me.Controls with FrmName.Controls but this doesn't work either.
Any ideas? I'm sure it's really simple!?