Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable controls in subform

Status
Not open for further replies.

TimGoff

Technical User
Jul 16, 2002
166
GB
Hi,

I've written a sub (below) to disable controls on forms in my db.

It disables the controls in a form fine using -

sDisableControls Me, True

...but i would like to disable the controls on a subform, by calling it from the form using -

sDisableControls frmFormatRightsSubform.Form, True

It doesn't error but just doesn't do anything.

Anybody any ideas?

Thanks
Tim

Sub sDisableControls(frmForm As Form, blnLockStatus As Boolean)
Dim ctlControl As Control
On Error GoTo ErrorsDisableControls
For Each ctlControl In frmForm.Controls
Select Case ctlControl.ControlType
Case acTextBox
ControlLocked ctlControl, blnLockStatus
Case acListBox
ControlLocked ctlControl, blnLockStatus
Case acComboBox
ControlLocked ctlControl, blnLockStatus
Case acCheckBox
ControlLocked ctlControl, blnLockStatus
Case acCommandButton
ControlEnabled ctlControl, blnLockStatus
End Select

Next ctlControl

ErrorsDisableControls:

Resume Next

End Sub
 
Sorry, ignore me it does work, just how I had the code organised.

But....

Any advice on code must appreciated!

Tim
 
Didn't see your last posting (must invest in Broad Band, keeps happening, there was no Answer when I Refreshed immediately before submitting).

Try putting your Functions, sDisableControls and ControlLocked (I assume ControlLocked is another Function) in a Module like this, so yhey will work with any Form in your app:

Public Function sDisableControls(frmForm As Form, blnLockStatus As Boolean)

Is that what you mean about advice on code.
 
Hi Bill,

General advice on what i'd written really - i'm still fairly new to VBA, so always looking for ways to improve what i've done (because no doubt there is plenty of scope for that)

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top