Solved

Combobox issue

Posted on 2016-11-12
4
37 Views
Last Modified: 2016-11-15
I don't think I've run into this before.  I have a form that has a combobox.  The combobox row source is a select query that gets its records from a table.  The table has a new yes/no field named "Inactive".  If a record has the yes/no field marked "True" then the record does not show up in the combo-box.  This is the way it should work for new records on the form.

But the problem is, for any existing records, when the form displays a record, the combo-box displays nothing.  I would like it to display the value if it is not a new record even if the combobox record is marked "True".

Ho do I get around this issue?
0
Comment
Question by:SteveL13
  • 2
4 Comments
 
LVL 19
ID: 41884650
There is only one RowSource for the combobox so the list is the same for all records. Perhaps instead of filtering out the inactive records, you can sort them to be at the bottom and show Inactive in another column. On the BeforeUpdate event of that control, test the Inactive column and if it is True, then give the user a message that they must pick an active value and Cancel the BeforeUpdate event to give them a chance to change their selection.

Optionally, you can modify the RowSource of the combobox depending on what you want for each record.  I prefer the above method.
1
 

Author Comment

by:SteveL13
ID: 41884697
I just had an idea and would like to know what you think.  In addition to the combobox I have created a text box with a DLookup control source to get the value of the combobox when the record was created.  I have the text box and the combo box on top of each other.

Then I have this code in the oncurrent event of the form...

    If Me.NewRecord = False Then
        Me.txtDeal.Visible = True
        Me.cboDeal.Visible = False
    Else
        Me.txtDeal.Visible = False
        Me.cboDeal.Visible = True
    End If

Open in new window

0
 
LVL 57

Assisted Solution

by:Jim Dettman (Microsoft MVP/ EE MVE)
Jim Dettman (Microsoft MVP/ EE MVE) earned 250 total points
ID: 41884780
<< I have created a text box with a DLookup control source to get the value of the combobox when the record was created.  I have the text box and the combo box on top of each other.>>

 Good idea using two controls, but rather than a text box, a third option is to use two combo's and switch between them.

 The other two options are the ones Crystal suggested.

  I like the approach of using a single combo, with all options, then use BeforeUpdate to test active/inactive.   While not the best approach from a UX viewpoint, it's the most efficient overall.

Jim.
1
 
LVL 19

Accepted Solution

by:
crystal (strive4peace) - Microsoft MVP, Access earned 250 total points
ID: 41884943
rather than actually showing the user the inactive value of True or False, you can use an equation to show something more meaningful. Perhaps something like:
Inactive_: IIF(Inactive=true, "Inactive","")
or
Activ: IIF(Inactive=true, "","A")
or
CanPick: IIF(Inactive=true, "","Yes")

Open in new window

0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
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…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

776 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