Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo box: display vs dropdown list 1

Status
Not open for further replies.

rfoye

Programmer
Oct 15, 2004
40
US
I'm hoping I can do this with just the combo box instead of a combo box and an overlapping text box.

I have a combo box that displays a Processor's name, but the value stored is the UserID (hidden column 1 of the combo box).

If a processor is no longer with the company, I want the box to display that user's name, but for new records (or editing old records) I do NOT want the user to be able to pick an Inactive processor.

If I set the rowsource to exclude inactive users, the name will not display on existing records where the user is inactive. Is there a way to temporarily filter the row source while selecting from the drop-down list?

-------------------
Rob Foye
Database Management
Regions Bank
 
add a column to the combo rowsource to indicate wheter the
Processor is active and in the control's before update event

Code:
If Me.Combobox.Column(xxx) = False Then
    Cancel = true
End If
 
I'd suggest adding a msgbox to let the user know why his/her selection did not work. Also, don't forget that numbering of columns in the combo box starts with 0.


Randy
 
Both of you misunderstood my question. I don't want incative users to appear in the list at all (when selecting).

-------------------
Rob Foye
Database Management
Regions Bank
 
In the GotFocus event of the combo box, put this (make it be the same as the rowsource you have now, except add the WHERE BLAH = False where BLAH = the name of the field that you indicate that someone is 'Inactive'):

Me.ComboBox.RowSource = "Select * from ProcessorsTable where Inactive = False"


Then in the LostFocus even put:

Me.ComboBox.Rowsource = "ProcessorsTable"

(or whatever your current rowsource is).

Try that.

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
If a processor is no longer with the company, I want the box to display that user's name," Post 1
"Both of you misunderstood my question. I don't want incative users to appear in the list at all (when selecting)." Post 4

Yeah, we all out here misunderstood. Our fault.
 
I understand what Rob wants. Usually you put a fakey text box over the combo box. This is a situation I've had a few times.

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
GingerR: Your suggestion of putting the "filter" in the GotFocus event worked perfectly! Before making the initial post, I had tried that in the MouseDown event, and it didn't work. I keep forgetting "If at first it doesn't succeed, try a different event."

Even better is that even if I tab into the field first, the Name of the Inactive processor remains, but the drop-down does not contain that name. Just what I wanted.

-------------------
Rob Foye
Database Management
Regions Bank
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top