Log in

View Full Version : Solved: disable deactivate form button...



slchslch
08-24-2005, 12:24 AM
i dont know whether this is possible or not, that why i intend to post up here..
If let said i have 2 access form, Form A and Form B. When certain criteria have fullfill in Form A, Form B button will be disable, is this situation can happen?

i have wrote some code, but dont know how to continue...

Private Sub disableButton(frm As Form)
Dim ctl As Control
For Each ctl In frm.Controls
If StrComp(ctl.Name, "xxx") Then
'intend to disable the button here
Exit For
End If
Next ctl
End Sub

Norie
08-24-2005, 05:36 AM
Can't you just use this?

ctl.Enabled = False

slchslch
08-24-2005, 05:57 PM
Can't you just use this?

ctl.Enabled = False

ya i have tried that before, but it seem like this object properties does not support in this situation.http://vbaexpress.com/forum/images/smilies/think.gif

xCav8r
08-24-2005, 06:36 PM
Have you tried...?

Me.ControlName.Enabled = False

slchslch
08-24-2005, 09:53 PM
Have you tried...?

Me.ControlName.Enabled = False

i should said that i call the function in Form A but intend to disable button in form B...so i think cant use Me.xxxx right?

xCav8r
08-24-2005, 09:55 PM
Right, but you reference it using Forms or Form. I forget the exact syntax.

slchslch
08-24-2005, 10:13 PM
okie..i have figure out the solution. Actually very easy, i just forgot the syntax out of sudden, here is my solution.

Dim frm As Form
Set frm = Forms!yourForm
frm!yourButtonName.Enabled = False

xCav8r
08-24-2005, 10:15 PM
slchslch roxrox!!

slchslch
08-24-2005, 11:21 PM
so sorry i think i made a mistake here....this code just working on those active form , which mean if the form still have not active yet(not yet open), this code doe not work.

my question is , is there a way to control those inactive form components?http://vbaexpress.com/forum/images/smilies/banghead.gif

Norie
08-25-2005, 08:33 AM
You would probably have to open the forms.