Solved

Disabling Buttons - What am I getting wrong?

Posted on 2011-02-16
3
240 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
[X]
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
  • 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
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…

756 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