Solved

Disabling Buttons - What am I getting wrong?

Posted on 2011-02-16
3
236 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
Comment Utility
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
Comment Utility
The same code should go into the afterupdate event procedure of BOTH combos.
0
 
LVL 15

Expert Comment

by:cquinn
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

771 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

12 Experts available now in Live!

Get 1:1 Help Now