Solved

Disabling Buttons - What am I getting wrong?

Posted on 2011-02-16
3
237 Views
Last Modified: 2012-05-11
I have two combo boxes and I want a button on the form disabled until something is selected from both combo boxes.  What am I getting wrong with this code?  It's probably the "" syntax I am getting wrong.

Private Sub Cashier_AfterUpdate()

    If Me.Cashier = "" And Me.Order = "" Then
    Me.btn_add_discussion.Enabled = False
    Else: Me.btn_add_discussion.Enabled = True

End If

End Sub

Open in new window

0
Comment
Question by:smods
  • 2
3 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 125 total points
ID: 34905891
If you only want the button enabled when BOTH selections have been made then you should have..

  If nz(Me.Cashier,"") = "" OR nz(Me.Order,"") = "" Then
0
 
LVL 77

Expert Comment

by:peter57r
ID: 34905906
The same code should go into the afterupdate event procedure of BOTH combos.
0
 
LVL 15

Expert Comment

by:cquinn
ID: 34905978
I would suggest that you use the Listindex property of the combos, rather than the text, and you don't have to set the property in two places:

Put this in the After_update of both combos:

  Me.btn_add_discussion.Enabled = (Me.Cashier.ListIndex <> -1 AND Me.Order.ListIndex <> -1)
 
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
IIf statement in ACCESS Criteria 5 26
Storing Combo Box Selection in Table 12 41
MS Access Order Smallest to Biggest Query Help 13 39
Importing and Dropping Table in Access 11 22
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now