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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Comboboxes visible/hidden on selection in other combo - code wrong? 1

Status
Not open for further replies.

schredder

Technical User
Feb 6, 2003
48
AE
Hi.Have a form with a combo "cboproduktekategorie". Based on the selection in this combo i want to become another combo (either "cbofm","cboip","cbomta","cbodd" or "cbodiv") visible. i have set the five combos' visible property to false and placed the following code in the afterupdate event of combo "cboproduktekategorie". but neither of the five combos appear, independent of what i select in "cboproduktekategorie". here's the code:

Private Sub cboproduktekategorie_AfterUpdate()
Select Case Me.cboproduktekategorie
Case "FM"
Me.cbofm.Visible = True
Case "IP"
Me.cboip.Visible = True
Case "MTA"
Me.cbomta.Visible = True
Case "DD"
Me.cbodd.Visible = True
Case "Diverses"
Me.cbodiv.Visible = True
End Select
End Sub

Think its an easy one - but i'm stuck. Any help greatly appreciated. Thanks. Chris
 
i yhink your code looks fine but is the combobx returning the right value??
and if you make one visible be sure the others are invisible
and dont forget to set this code in the on current of the form if that is what you want

Select Case Me.cboproduktekategorie
Case "FM"
Me.cbofm.Visible = True
Me.cboip.Visible = false
Me.cbomta.Visible = false
Me.cbodd.Visible = false
Me.cbodiv.Visible = false
...
End Select
Christiaan Baes
Belgium
"What a wonderfull world" - Louis armstrong
 
Hey Christiaan. Got it working somehow. I had to change the rowsource property of the combo "cboproduktekategorie" to valuelist and then type "FM","IP",.. by myself and then it worked. B4 i had the combo looking up the values in a table. Why is that ? Is there no way that this works the way i had it ?
 
normally yes. but is it possible that you took more then one field out of the table, like also the id. this wouldnt show up in the combobox but would have been the bound cloumn of the combo. then if you call the combobox value it would take the id instead of the value you want.
you could check this by placing a textbox on your form and call it textboxcontrol then type this in the afterupdate of the combobox (the one with the table)

Select Case Me.cboproduktekategorie
Case "FM"
Me.cbofm.Visible = True
Case "IP"
Me.cboip.Visible = True
Case "MTA"
Me.cbomta.Visible = True
Case "DD"
Me.cbodd.Visible = True
Case "Diverses"
Me.cbodiv.Visible = True
End Select
textboxcontrol = Me.cboproduktekategorie.column(0)

if you see a value or not the text you choose in the textbox you know the value you have is falty then try changing the column(0) to column(1) and check what this gives
Christiaan Baes
Belgium
"What a wonderfull world" - Louis armstrong
 
u r right. it showed me the ID and when changing the column it gave me the values i wanted. Think i have to change the statement in the row source property of the combo then. This is what i have:

SELECT [Produktekategorie].[Produktekategorie-ID], [Produktekategorie].[Produktekategorie] FROM Produktekategorie;

(tried deleting "[Produktekategorie].[Produktekategorie-ID]", but obviously didnt work.)
chris
 
yes it will work if you go to the properties of the combobox and change the columnwidths from (probably) 0cm;2.54cm or something like that to 2.54cm and change the number of columns (thats on the same tabpage) to 1 instead of 2
Christiaan Baes
Belgium
"What a wonderfull world" - Louis armstrong
 
gr8, thanks a lot Christiaan. One last thing which is disturbing: when browsing through the data in the form, the one combobox which has been selected at last (from the last data entry) keeps beeing visible throughout all the data (although the data in the underlying table keeps beeing saved correctly). Any suggestions?
Thanks and a smile
Chris
 
i think i already said that you should put this in the on current event of the form

call cboproduktekategorie_AfterUpdate

and if you really want to thank me click mark this post...
Christiaan Baes
Belgium
"What a wonderfull world" - Louis armstrong
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top