473,408 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Handling Combo box Active/Inactive rows?

I was wondering how you handle active/inactive elements in a combo box.
Let's say you have a combo box to select an employee. Joe Blow has
been selected for many record however Joe has left the company and has
been flagged inactive. If you have a filter on the rowsource like
Where Active = True
then Joe's name would not show up in the combo list. This would be fine
if the combo is associated with a field that is null/0. It would not be
fine if this is an older record created when Joe was active as his name
would not be in the list and the combo would be blank.

Do you do present the combo with a filter like
Where (Active = True) or (EmpID = [ID])
or do you present only active emps if the record is new/combo unfilled
and present all if the record is not new/combo filled? IOW, change the
rowsource depending on the existing value of the field to be selected?
Or do even bother and just show all emps regardless of their active status?
Nov 6 '06 #1
8 8214
The simplest solution is to sort the inactive records to the bottom. That
way the old names still show correctly (even if the bound column is hidden),
but as you type a name, it always chooses the active ones.

This kind of thing:
SELECT ClientID, Surname & ", " & FirstName AS FullName
FROM tblClient
ORDER BY Inactive DESC, Surname, FirstName;

BTW, I've developed the habit of using a saved query for these little
lookups. Then if the end user does decide they want a different result (such
as eliminating the inactive ones from the combo), there is just one query to
change, and every place in the app that uses this combo will update
correctly.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"salad" <oi*@vinegar.comwrote in message
news:_M****************@newsread2.news.pas.earthli nk.net...
>I was wondering how you handle active/inactive elements in a combo box.
Let's say you have a combo box to select an employee. Joe Blow has been
selected for many record however Joe has left the company and has been
flagged inactive. If you have a filter on the rowsource like
Where Active = True
then Joe's name would not show up in the combo list. This would be fine
if the combo is associated with a field that is null/0. It would not be
fine if this is an older record created when Joe was active as his name
would not be in the list and the combo would be blank.

Do you do present the combo with a filter like
Where (Active = True) or (EmpID = [ID])
or do you present only active emps if the record is new/combo unfilled and
present all if the record is not new/combo filled? IOW, change the
rowsource depending on the existing value of the field to be selected? Or
do even bother and just show all emps regardless of their active status?

Nov 6 '06 #2
Allen Browne wrote:
The simplest solution is to sort the inactive records to the bottom. That
way the old names still show correctly (even if the bound column is hidden),
but as you type a name, it always chooses the active ones.

This kind of thing:
SELECT ClientID, Surname & ", " & FirstName AS FullName
FROM tblClient
ORDER BY Inactive DESC, Surname, FirstName;

BTW, I've developed the habit of using a saved query for these little
lookups. Then if the end user does decide they want a different result (such
as eliminating the inactive ones from the combo), there is just one query to
change, and every place in the app that uses this combo will update
correctly.
I like your idea of sinking the inactives to the bottom and floating the
actives to the top.
Nov 6 '06 #3
"Allen Browne" <Al*********@SeeSig.Invalidwrote in
news:45**********************@per-qv1-newsreader-01.iinet.net.au:
The simplest solution is to sort the inactive records to the
bottom. That way the old names still show correctly (even if the
bound column is hidden), but as you type a name, it always chooses
the active ones.
But you'd also want BeforeUpdate validation to prevent the choosing
of an inactive one.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Nov 6 '06 #4
salad <oi*@vinegar.comwrote in
news:73****************@newsread3.news.pas.earthli nk.net:
Allen Browne wrote:
>The simplest solution is to sort the inactive records to the
bottom. That way the old names still show correctly (even if the
bound column is hidden), but as you type a name, it always
chooses the active ones.

This kind of thing:
SELECT ClientID, Surname & ", " & FirstName AS FullName
FROM tblClient
ORDER BY Inactive DESC, Surname, FirstName;

BTW, I've developed the habit of using a saved query for these
little lookups. Then if the end user does decide they want a
different result (such as eliminating the inactive ones from the
combo), there is just one query to change, and every place in the
app that uses this combo will update correctly.

I like your idea of sinking the inactives to the bottom and
floating the actives to the top.
That sounds like a good idea to me, too.

Another thing you could do is include all of them in the combo box
that is used for display and editing, but when you're adding a new
record, filter them out.

And, as I said in the response to Allen, you'll need a BeforeUpdate
validation to prevent a user from changing the value to an inactive
employee.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Nov 6 '06 #5
salad wrote:
I was wondering how you handle active/inactive elements in a combo box.
Let's say you have a combo box to select an employee. Joe Blow has
been selected for many record however Joe has left the company and has
been flagged inactive. If you have a filter on the rowsource like
Where Active = True
then Joe's name would not show up in the combo list. This would be fine
if the combo is associated with a field that is null/0. It would not be
fine if this is an older record created when Joe was active as his name
would not be in the list and the combo would be blank.

Do you do present the combo with a filter like
Where (Active = True) or (EmpID = [ID])
or do you present only active emps if the record is new/combo unfilled
and present all if the record is not new/combo filled? IOW, change the
rowsource depending on the existing value of the field to be selected?
Or do even bother and just show all emps regardless of their active status?
Here are some partially related ideas about filtering on a checkbox in
case you need it:

Suppose I have a Y/N field called Exclude in a table. A search form in
Access containing an unbound checkbox can create a query that excludes
records where Exclude is checked in a table using syntax like

WHERE Exclude >= -(1 + Forms!frmSearch!chkExclude.Value)

I.e.,

Forms!frmSearch!chkExclude.Value = -1 =>
WHERE Exclude >= 0 [Excludes Checked Values]
Forms!frmSearch!chkExclude.Value = 0 =WHERE Exclude >= -1

This depends on a value of -1 for True. It can be modified as follows:

WHERE Abs(Exclude) <= 1 - Abs(Forms!frmSearch!chkExclude.Value)

I.e.,

Forms!frmSearch!chkExclude.Value = 1 or -1 =>
WHERE Abs(Exclude) <= 0 [Excludes Checked Values]
Forms!frmSearch!chkExclude.Value = 0 =WHERE Abs(Exclude) <= 1

But the OP wanted records where Active is not checked to disappear
rather than checked records to disappear:

The True = -1 dependent version of this is:

WHERE Active <= Forms!frmSearch!chkExcludeNonActive.Value

I.e.,

Forms!frmSearch!chkExcludeNonActive.Value = -1 =>
WHERE Active <= -1 [Excludes records with Active unchecked]
Forms!frmSearch!chkExcludeNonActive.Value = 0 =WHERE Active <= 0

A modified version:

WHERE Abs(Active) >= Abs(Forms!frmSearch!chkExcludeNonActive.Value)

I.e.,

Forms!frmSearch!chkExcludeNonActive.Value = -1 or 1 =>
WHERE Abs(Active) >= 1 [Excludes records with Active unchecked]
Forms!frmSearch!chkExcludeNonActive.Value = 0 =WHERE Abs(Active) >= 0

I realize that an Access form's checkbox value cannot equal 1. I
include that possibility to illustrate the SQL required to filter
against data containing either -1 or 1 to indicate True when an Access
form is not used to get the filter value.

James A. Fortune
CD********@FortuneJames.com

Nov 6 '06 #6
CD********@FortuneJames.com wrote:
salad wrote:
>>I was wondering how you handle active/inactive elements in a combo box.
Let's say you have a combo box to select an employee. Joe Blow has
been selected for many record however Joe has left the company and has
been flagged inactive. If you have a filter on the rowsource like
Where Active = True
then Joe's name would not show up in the combo list. This would be fine
if the combo is associated with a field that is null/0. It would not be
fine if this is an older record created when Joe was active as his name
would not be in the list and the combo would be blank.

Do you do present the combo with a filter like
Where (Active = True) or (EmpID = [ID])
or do you present only active emps if the record is new/combo unfilled
and present all if the record is not new/combo filled? IOW, change the
rowsource depending on the existing value of the field to be selected?
Or do even bother and just show all emps regardless of their active status?


Here are some partially related ideas about filtering on a checkbox in
case you need it:

Suppose I have a Y/N field called Exclude in a table. A search form in
Access containing an unbound checkbox can create a query that excludes
records where Exclude is checked in a table using syntax like

WHERE Exclude >= -(1 + Forms!frmSearch!chkExclude.Value)

I.e.,

Forms!frmSearch!chkExclude.Value = -1 =>
WHERE Exclude >= 0 [Excludes Checked Values]
Forms!frmSearch!chkExclude.Value = 0 =WHERE Exclude >= -1

This depends on a value of -1 for True. It can be modified as follows:

WHERE Abs(Exclude) <= 1 - Abs(Forms!frmSearch!chkExclude.Value)

I.e.,

Forms!frmSearch!chkExclude.Value = 1 or -1 =>
WHERE Abs(Exclude) <= 0 [Excludes Checked Values]
Forms!frmSearch!chkExclude.Value = 0 =WHERE Abs(Exclude) <= 1

But the OP wanted records where Active is not checked to disappear
rather than checked records to disappear:

The True = -1 dependent version of this is:

WHERE Active <= Forms!frmSearch!chkExcludeNonActive.Value

I.e.,

Forms!frmSearch!chkExcludeNonActive.Value = -1 =>
WHERE Active <= -1 [Excludes records with Active unchecked]
Forms!frmSearch!chkExcludeNonActive.Value = 0 =WHERE Active <= 0

A modified version:

WHERE Abs(Active) >= Abs(Forms!frmSearch!chkExcludeNonActive.Value)

I.e.,

Forms!frmSearch!chkExcludeNonActive.Value = -1 or 1 =>
WHERE Abs(Active) >= 1 [Excludes records with Active unchecked]
Forms!frmSearch!chkExcludeNonActive.Value = 0 =WHERE Abs(Active) >= 0

I realize that an Access form's checkbox value cannot equal 1. I
include that possibility to illustrate the SQL required to filter
against data containing either -1 or 1 to indicate True when an Access
form is not used to get the filter value.

James A. Fortune
CD********@FortuneJames.com
Yeah, I know how to filter. That's only part of the question.

Let's say you were my employee until last week. IF I had something like
Select Emp.* From Employee Where Active = True
for the combo box rowsource, you would not appear in records that I've
added this week. That's well and good.

But if I used that combo and reviewed a record where you were selected
from last week or before that field would be blank. The EmpID value
would still exist, but the combo would be blank.

So do I change it to
Select Emp.* From Employee
Where Active = True Or EmpId = [EmpID]
Now I show all active records or the value for the ID selected previously.

I suppose I could check in the OnCurrent event. If the record is new or
the value blank, create a SQL statement to select all records that are
active and stuff into the rowsource. If old record or value filled in,
create a SQL statement to select all records regardless of active status
and make that the rowsource.

I like Allen's approach to sorting the names by active status. This way
I am not designing rowsources depending on status of the record or value
of the combo.
Nov 7 '06 #7
Yes, good thought.

I usually warn (rather than block) in Form_BeforeUpdate.
Sometimes old data needs be be entered.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"David W. Fenton" <XX*******@dfenton.com.invalidwrote in message
news:Xn**********************************@127.0.0. 1...
"Allen Browne" <Al*********@SeeSig.Invalidwrote in
news:45**********************@per-qv1-newsreader-01.iinet.net.au:
>The simplest solution is to sort the inactive records to the
bottom. That way the old names still show correctly (even if the
bound column is hidden), but as you type a name, it always chooses
the active ones.

But you'd also want BeforeUpdate validation to prevent the choosing
of an inactive one.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/

Nov 7 '06 #8
salad wrote:
Yeah, I know how to filter. That's only part of the question.
I was hoping to avoid the question :-).
>
Let's say you were my employee until last week. IF I had something like
Select Emp.* From Employee Where Active = True
for the combo box rowsource, you would not appear in records that I've
added this week. That's well and good.

But if I used that combo and reviewed a record where you were selected
from last week or before that field would be blank. The EmpID value
would still exist, but the combo would be blank.

So do I change it to
Select Emp.* From Employee
Where Active = True Or EmpId = [EmpID]
Now I show all active records or the value for the ID selected previously.

I suppose I could check in the OnCurrent event. If the record is new or
the value blank, create a SQL statement to select all records that are
active and stuff into the rowsource. If old record or value filled in,
create a SQL statement to select all records regardless of active status
and make that the rowsource.

I like Allen's approach to sorting the names by active status. This way
I am not designing rowsources depending on status of the record or value
of the combo.
Thanks for the detailed explanation. I understand the problem.
Allen's idea is a good one but the question is a good one also. I'll
spend some time late tonight thinking about it.

James A. Fortune
CD********@FortuneJames.com

Nov 7 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Salad | last post by:
On you form you have a combo box of a list of employees. In the Employee table you have the employee name, employee id, and an ActiveInactive status. Initially, the list contains the names of...
3
by: Mark | last post by:
I have a form that contains the following: 2 radio buttons (Name and Number) 1 check box (for Inactive Members) 1 combo box (list of Member names or numbers) I use the radio buttons to...
2
by: Kelly | last post by:
I have a subform that display requisition information. One of the fields in the subform is a combo box that shows who requested the requisition. The users can change who requested the requisition...
5
by: meganrobertson22 | last post by:
I have a simple form, frmProduct, with a combo box, cboStatus, that has 2 choices: "Active" and "Inactive." If I chose "Inactive," then I want another combo box to appear, cboInactiveStatus, which...
6
by: Mickster | last post by:
Hi there I am currently making a sub form. The form will have a combo box and a option group. The combo box contains a list of four employees. The option group has to radio buttons labeled Active and...
1
by: Fritjolf | last post by:
Hi. I'm developing a testapplication, retrieving objects of type "Computer" from out AD server. More than 5000 are listed, and I know lots of these are set as inactive. I've seen some code...
4
by: reggiestyles | last post by:
Hi, I've got a question about prototype and event handling. I've got several div's (dynamic number) on a page that I want to set as active or inactive (basically, I'm using scriptaculous'...
2
by: jayashreeshankar | last post by:
hi all... i have used combo box in my application where using the action class i have inserted the values into the database. the bean is giving the already stored value and fails to refresh when...
20
by: Scldb | last post by:
I have a form needs to be filled out. A lot of the questions are a yes/no question. When they pick yes I want some other textboxes to be active, and when they pick no I want the textboxes to be...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.