wedd
01-23-2011, 10:32 AM
Hi everyone, I''m creating combo boxes which when the user clicks on the first combo box and select an optio from the list all the items that relate to it can be selected in the second combo box with options that relate to it. My first combo box called Location name shows the list Maitland Park Centre, Queen's Crescent Centre and Fleetwood centre; however my second combo box venueName is not recognising and takes me back into the vb editor highlighting on the code: Me.CboLocationName in yellow, and doesn't display the options that relate...I'm not sure why this is occuring as it seeems correct code.
My tables are as follow:
Loc which fireld are locationID, LocationName, LocationDescription and the second table which is called venuenames has the fields venueID, Venue names and locations. The code I am using to run on both combo boxes to display in relation to each other is written below. Any reason why this is happening? It could be something obvious which I haven't noticed; but as mentioned earlier the first combo box populated with a drop down list, but the second hasn't. Thanks for your contributions:friends:
My final outcome should be:
Combo box 1 selects Location name Maitland Park Sports center and in combo box 2 (venue names) there should be options to choose from which are Sports, Classroom.
If the user selects Combox1 again (Locationname) and selects Queen Crescent Centre the second combo box should display Main Hall 1, Main Hall 2, Multimedia suite, IT-Drop In, and Gym to choose from the list.
And thirdly, if the user selects Fleet Community centre from combo box 1(Locationname) when he selects from combo box 2 (venuename) the options meeting hall and side room should be displayed for the user to choose from. I've listed my code below:
Private Sub CboLocationName_AfterUpdate()
Me.cboVenue.RowSource = "SELECT VenueName FROM" & _
" VenueName WHERE LocationID = " & Me.CboLocationName & _
" ORDER BY VenueName "
Me.CboVenueName = Me.CboVenueName.ItemData(0)
End Sub
My tables are as follow:
Loc which fireld are locationID, LocationName, LocationDescription and the second table which is called venuenames has the fields venueID, Venue names and locations. The code I am using to run on both combo boxes to display in relation to each other is written below. Any reason why this is happening? It could be something obvious which I haven't noticed; but as mentioned earlier the first combo box populated with a drop down list, but the second hasn't. Thanks for your contributions:friends:
My final outcome should be:
Combo box 1 selects Location name Maitland Park Sports center and in combo box 2 (venue names) there should be options to choose from which are Sports, Classroom.
If the user selects Combox1 again (Locationname) and selects Queen Crescent Centre the second combo box should display Main Hall 1, Main Hall 2, Multimedia suite, IT-Drop In, and Gym to choose from the list.
And thirdly, if the user selects Fleet Community centre from combo box 1(Locationname) when he selects from combo box 2 (venuename) the options meeting hall and side room should be displayed for the user to choose from. I've listed my code below:
Private Sub CboLocationName_AfterUpdate()
Me.cboVenue.RowSource = "SELECT VenueName FROM" & _
" VenueName WHERE LocationID = " & Me.CboLocationName & _
" ORDER BY VenueName "
Me.CboVenueName = Me.CboVenueName.ItemData(0)
End Sub