Solved

Combobox issue

Posted on 2016-11-12
4
25 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 18
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 18

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

706 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

16 Experts available now in Live!

Get 1:1 Help Now