Consulting

Results 1 to 10 of 10

Thread: Solved: disable deactivate form button...

  1. #1
    VBAX Regular
    Joined
    Jun 2005
    Posts
    30
    Location

    Solved: disable deactivate form button...

    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...
    [VBA]
    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
    [/VBA]

  2. #2
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    Can't you just use this?
    [vba]
    ctl.Enabled = False[/vba]

  3. #3
    VBAX Regular
    Joined
    Jun 2005
    Posts
    30
    Location
    Quote Originally Posted by Norie
    Can't you just use this?
    [vba]
    ctl.Enabled = False[/vba]
    ya i have tried that before, but it seem like this object properties does not support in this situation.

  4. #4
    VBAX Expert xCav8r's Avatar
    Joined
    May 2005
    Location
    Minneapolis, MN, USA
    Posts
    912
    Location
    Have you tried...?

    [VBA]Me.ControlName.Enabled = False [/VBA]

  5. #5
    VBAX Regular
    Joined
    Jun 2005
    Posts
    30
    Location
    Quote Originally Posted by xCav8r
    Have you tried...?

    [VBA]Me.ControlName.Enabled = False [/VBA]
    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?

  6. #6
    VBAX Expert xCav8r's Avatar
    Joined
    May 2005
    Location
    Minneapolis, MN, USA
    Posts
    912
    Location
    Right, but you reference it using Forms or Form. I forget the exact syntax.

  7. #7
    VBAX Regular
    Joined
    Jun 2005
    Posts
    30
    Location
    okie..i have figure out the solution. Actually very easy, i just forgot the syntax out of sudden, here is my solution.
    [VBA]
    Dim frm As Form
    Set frm = Forms!yourForm
    frm!yourButtonName.Enabled = False
    [/VBA]

  8. #8
    VBAX Expert xCav8r's Avatar
    Joined
    May 2005
    Location
    Minneapolis, MN, USA
    Posts
    912
    Location
    slchslch roxrox!!

  9. #9
    VBAX Regular
    Joined
    Jun 2005
    Posts
    30
    Location
    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?

  10. #10
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    You would probably have to open the forms.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •