Enable Disable Fields Criteria

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

Enable Disable Fields Criteria

Post by burrina »

If PaymentMethod = Check or Cash then CreditCard & CardHolder not enabled. Those are field names. bound
But my code is not disabling the fields? I use both the OnCurrent & AfterUpdate Events.
Dim bln As Boolean

bln = (Nz(Me.PaymentMethod, "") = "Check")

Me.CheckNo.Enabled = bln
Me.CardHolder.Enabled = Not bln
Me.CreditCard.Enabled = Not bln
Me.Refresh

User avatar
HansV
Administrator
Posts: 74138
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Enable Disable Fields Criteria

Post by HansV »

It looks OK, but try the following instead:

Code: Select all

    Select Case Me.PaymentMethod
        Case "Cash"
            Me.CheckNo.Enabled = False
            Me.CardHolder.Enabled = False
            Me.CreditCard.Enabled = False
      Case "Check"
            Me.CheckNo.Enabled = True
            Me.CardHolder.Enabled = False
            Me.CreditCard.Enabled = False
      Case Else
            Me.CheckNo.Enabled = False
            Me.CardHolder.Enabled = True
            Me.CreditCard.Enabled = True
    End Select
You can add other cases of course.
Regards,
Hans

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

Re: Enable Disable Fields Criteria

Post by burrina »

Many Thanks, I wrote that a long time ago and confused myself with my own code! Ha!
Thanks,