Solved

Disabling Buttons - What am I getting wrong?

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
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…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

770 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