Combobox hide values already in table (1 Viewer)

Japaner84

New member
Local time
Today, 02:05
Joined
Oct 18, 2019
Messages
1
Hello,
I have a combobox and in there you have values to choose from, but what I want is that once you have chosen a value from the box it is no longer possible to chose it again/it gets hidden in the combobox, meaning that so long as the value is saved in the table it's also hidden in the combobox.
Is there any way to do this?
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 05:05
Joined
Apr 27, 2015
Messages
6,319
Good morning and welcome to AWF!

Got a question, most combobox options are derived from a table or query. You seem to want to have only values that are NOT in a particular table. If I understand you correctly, then where are the combobox values coming from?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:05
Joined
May 7, 2009
Messages
19,229
if you combo is Rowsource Type is Value List, you can Remove the item from the combo.
there is no event to hide the item.
add code to the Form's After Update event.
Code:
Private Sub Form_AfterUpdate()
    Dim i As Integer
    For i = Me.ComboX.ListCount - 1 To 0 Step -1
        If DCount("1", "TableName", "[FieldName]='" & Me.ComboX.ItemData(i) & "'") > 0 Then
            Me.ComboX.RemoveItem i
        End If
    Next
        
End Sub
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:05
Joined
Oct 29, 2018
Messages
21,449
Hi. Welcome to AWF! I have different question. Are you using this combobox in a continuous view form?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 04:05
Joined
Feb 28, 2001
Messages
27,131
If this is a value list combo box, it wouldn't take much to empty it. If the combo box gets its values from a table of possible values, you could define the .RowSource query that drives the combo box to include a WHERE clause, ...

Code:
WHERE value NOT IN ( SELECT usedvalue FROM usedvaluetable )
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 05:05
Joined
Feb 19, 2002
Messages
43,213
The rowsource for your combo can include a join to the table/query the form is bound to. Use a left join and WHERE criteria.

Where FKfieldInFormsTable is Null.
 

Users who are viewing this thread

Top Bottom