473,397 Members | 1,972 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,397 software developers and data experts.

Combo Box I want to show Old Values but not when updating

In my database I have a form that allows the user to view and update data. I use combo boxes to standardize entry of the data. The issue that I have found with combo boxes is that when the data goes out of date, i.e. the Employee leaves, the user can no longer see the employee on the form. This has to do with the list values being limited to Active Employees.

What I want to do is show all of the employees on the form but only allow the user to select the active employees when they are updating the record.

How do you get around this issue?
Jun 12 '15 #1

✓ answered by jforbes

I think this behavior only happens when using a key column and an additional display (human readable) column, and maybe Limit to List turned on. If you were to save the Employees name into the Record on the Form, it would display inactive Employees, but only allow you to select active Employees.

That would probably be a pretty serious change for you, so you might want to include the currently selected Employee in the RowSource for the ComboBox. It's not as clean, but it would be prettier than what you have. To do this, include something like this as the RowSource of the ComboBox:
Expand|Select|Wrap|Line Numbers
  1. SELECT Employee.ID, Employee.FullName, Employee.Active
  2. FROM Employee
  3. WHERE Employee.Active=True 
  4. OR Employee.ID=[Forms]![TheCurrentForm]![ComboBoxName]
Then you'll need to add a Requery in the OnCurrent Event of the Form:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.     Me.ComboBoxName.Requery
  3. End Sub

6 1464
Seth Schrock
2,965 Expert 2GB
You could use the control's BeforeUpdate event to check if the employee is active. If they are not, then cancel the event, undo the change and show a message. Here is an example from the MSDN website: ComboBox.BeforeUpdate Event.

To help the users know which ones are active, you could add another column to your combobox that displays this information. It would only show when the box is expanded, but it would help.
Jun 12 '15 #2
Thanks Seth, I solved this by adding a text box that contains the Employee's name from the lookup table as a part of my base query, then making the combo box shrink to show only the drop down arrow part of the box and limited the combo box list to active employees. By putting combo box next to the text box the user is able to see them as if they were one field. When they open the Combo box list they are able to select an active employee and the text box updates automatically.

It feels messy to me but it does what I needed. I am open to feedback on this method of solving the problem of seeing the employee currently selected, who may no longer be an employee, and allowing selection of only active employees.
Jun 12 '15 #3
jforbes
1,107 Expert 1GB
I think this behavior only happens when using a key column and an additional display (human readable) column, and maybe Limit to List turned on. If you were to save the Employees name into the Record on the Form, it would display inactive Employees, but only allow you to select active Employees.

That would probably be a pretty serious change for you, so you might want to include the currently selected Employee in the RowSource for the ComboBox. It's not as clean, but it would be prettier than what you have. To do this, include something like this as the RowSource of the ComboBox:
Expand|Select|Wrap|Line Numbers
  1. SELECT Employee.ID, Employee.FullName, Employee.Active
  2. FROM Employee
  3. WHERE Employee.Active=True 
  4. OR Employee.ID=[Forms]![TheCurrentForm]![ComboBoxName]
Then you'll need to add a Requery in the OnCurrent Event of the Form:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.     Me.ComboBoxName.Requery
  3. End Sub
Jun 13 '15 #4
NeoPa
32,556 Expert Mod 16PB
I have a very similar situation. Seth's approach works fine for me.
Jun 13 '15 #5
jforbes
1,107 Expert 1GB
Oh, yes. I didn't mean to say that Seth's approach wouldn't work. It's a great approach, especially if you want to allow your users to select inactive employees and warn that they are doing so.

I just wanted to offer it up as an option, because there are times when only an active employee should be selected. For me, limiting the list to only active employees is preferable to listening to users ask me, "If we are not supposed to select inactive employees, then why are they in the list?"
Jun 15 '15 #6
NeoPa
32,556 Expert Mod 16PB
JForbes:
"If we are not supposed to select inactive employees, then why are they in the list?"
My answer to that one is the simple truth - Because the list covers existing records as well as valid selections for new or updated ones.

Having said that, your suggestion is perfectly valid. It's a tidy solution if twittering users are a problem (and they can be). There's always room for more solutions.
Jun 15 '15 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Scott_From_PA | last post by:
I have a love hate thing going with Dreamweaver! One of the things I absolutely hate is the properties box when modifying form objects. Lets say you lay out a form in a table and it comes time...
2
by: TD | last post by:
This should be simple but I can't figure it out! I have a form bound to a query. On this form is a combo box that is bound to the same query. When the form loads the combo box is blank. If you...
0
by: Codex | last post by:
I'm using VC++ in Visual Studio 2003 to write a .NET wrapper class which accesses some unmanaged c code. When debugging, I've noticed that sometimes the debugger won't show values of unmanaged...
10
by: jaYPee | last post by:
does anyone experienced slowness when updating a dataset using AcceptChanges? when calling this code it takes many seconds to update the database SqlDataAdapter1.Update(DsStudentCourse1)...
2
by: Jason Huang | last post by:
Hi, I am wondering why use the DataTableMapping in SqlDataAdapter when Updating data. Would someone give me some advice? Thanks for help. Jason
0
by: bz | last post by:
Hi, I have a datagrid with two columns Region and City Both have combo-boxes. City column is unbound What I want is, when use select a region, to fill the combo for City column with appropriate...
3
by: Reg Verrin | last post by:
I have a program that displays constantly changing prices which it sources from the web once per second. The prices are displayed on a Listbox (not the best choice but there are good reasons for...
1
by: damonrulz | last post by:
If I have two combo boxes (Combo1 & Combo2) and when a certain value in Combo1 is selected, the values in Combo2 that correspond with that value will show, and the rest will be hidden. For...
0
by: Arjun Sarankulu | last post by:
I have generated a utility to take a csv file and dump the data from csv to database. The utility is working fine. Now i want to add the categatory in the combo box which will come dynamically...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.