Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Disabling Buttons - What am I getting wrong?

Posted on 2011-02-16
3
239 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

856 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