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

Dispay a listbox based on another listbox's selection

Status
Not open for further replies.

Jackie

MIS
Feb 9, 2000
148
US
How do you display a field based upon a specific item selected in a listbox?

I created a form that contains a listbox (called lst_Region). If a specific item in the listbox is selected another listbox (lst_asia) should be displayed.

The following code is attached to the On-click event for the 1st listbox:

If Me!lst_Region!Selected(0) = True Then
Me!lst_asia.Visible = True
End If

When I click on the specific item in the first listbox, the following error message is displayed:

"Run-time Error 451 - Object Not a collection"

Any help would be appreciated. Thank you in advance.
 
A very little use of the debug window should solve this type problem. Place the cursor on the beginning of the 'if' statement and push {F9} to set a breakpoint. Run the form and select the first item in the listbox. This should then trap at the breakpoint where you can now use the debug window to inspect what is being returned.

Try entering:

?Me!lst_Region!Selected(0) and it will return the value you are testing for. If you get a runtime error then try !Selected(1). I strongly suspect you need to replate the exclamation point with a period before 'selected' but it is best to inspect it and find out yourself.

Steve King Growth follows a healthy professional curiosity
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top