Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2011

    Unanswered: Enable / Disable Command Button

    Hi All,

    I need an urgent help setting a query or macro in ACCESS to enable or disable a command button based on set criteria.


    I have a form called "Entry Table" which contain the following:

    1) 2 text boxes for users to enter customer ID and Ref number
    2) 3 validation select criteria called
    name select
    varify1 Yes
    varify2 No
    varify3 yes
    3) a command button called "command12". with onclick event procedure that allows varify1, varify2 and varify3 to atomatically select "yes" if the custmer ID and ref number is valid and "NO" if not valid. this part is working.
    4) a text box called "validcheck" with the formula: iif([varify1]="yes" and [varify2]="yes" and [varify3] ="yes",1,0). This will mean that the customer ID and ref number is valid if varify1, varify2 and varify3 are selected yes.
    5) a command button called "processmandate", which when "command12" is clicked, should enable only if "validcheck" = 1 and disable if "validcheck" = 0.

    The problem is that the "processmandate" keep enabling regardless of if "validcheck" equals 1 or 0. PLEASE HELP!

    Below is what I did but does not work, maybe i'm missing somthing:

    Private Sub Command12_Click()
    On Error GoTo Err_Command12_Click

    Dim stDocName As String

    stDocName = "Refresh"
    DoCmd****nMacro stDocName

    If [ValidCheck] > "0" = True Then
    Me.[processmandate].Enabled = True
    Me.[processmandate].Enabled = False
    End If

    Exit Sub

    MsgBox Err.Description
    Resume Exit_Command12_Click

    End Sub

    Thank you
    Last edited by Joleks; 10-20-11 at 08:45.

  2. #2
    Join Date
    Mar 2009
    Provided Answers: 15
    Provided the formula for computing ValidCheck is correct, try:
    Me.processmandate.Enabled = (Me.ValidCheck.Value <> 0)
    Have a nice day!

  3. #3
    Join Date
    Oct 2011

    Enable / Disable Command Button

    Many thanks Sinndho,

    I tied your suggestion but it didn't work. I can confirm that the validcheck formula is correct and working. Any more suggestion?

    Many thanks again
    Last edited by Joleks; 10-20-11 at 10:14.

  4. #4
    Join Date
    Mar 2009
    Provided Answers: 15
    Can you place a breakpoint on the line of code I supplied and check that it is executed? If it is, can you verify the value of ValidCheck at that moment?

    If all that is correct, continue the execution of the code step by step (F8 key): there must be something that's executed later and that changes the Enabled property of the control again.
    Have a nice day!

Posting Permissions

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