change which row in a combo box is visible depending on event

hubcap750

Registered User.
Local time
Today, 15:46
Joined
Jun 27, 2013
Messages
34
Hi All,

I have a combo box with three columns, the first one is the bound one, the second is text in English, and the third is text in Spanish. Currently when the form is open, both the English and Spanish texts columns are visible. What I would like to do is set up a command button on a different form that will open the form with just the English showing in the combo boxes, and another button for Spanish. I've tried the following code which opens the form, but the combo box is disabled altogether.

DoCmd.OpenForm "frmEditar", acNormal, "", "", , acNormal
DoCmd.SetProperty "niv_gest", acPropertyColumnWidths, "0;1;1"

What am I missing?
 
You can have only one column and alter the SQL of the Record Source to return the relevant field, then Requery your combo box.

Or

Transpose your data so that instead of they being columns (or fields), they will be rows (or records) of data, then you use criteria to filter accordingly.
 
That worked great!. I first had to set the default on the load form event so it would default, but then I added the code to the after update event and it worked great for all 15 combo boxes! Here's the code for just one of then in case someone else out there is trying to do the same thing:

Private Sub ComboLang_AfterUpdate()
If Me.ComboLan.Value = 1 Then

Me.Niv_gest.RowSource = "SELECT buscar_nivel_gestion.nivel_gestion_id, buscar_nivel_gestion.nivel_gestion FROM buscar_nivel_gestion ORDER BY buscar_nivel_gestion.nivel_gestion_id"

Else

Me.Niv_gest.RowSource = "SELECT buscar_nivel_gestion.nivel_gestion_id, buscar_nivel_gestion.man_level FROM buscar_nivel_gestion ORDER BY buscar_nivel_gestion.nivel_gestion_id"

End If

End Sub

I'd mark this thread solved if I could figure out how to do that!
 
Good job! You'll need that in the Current Event of the form as well.

What can you not figure out exactly?
 
Sorry I wasn't thinking straight there.

At the very top of the thread, just above the blue frame of your first post, you'll see a dropdown menu called "Thread Tools", one of the items in the list is "Mark this thread as solved".
 

Users who are viewing this thread

Back
Top Bottom