PDA

View Full Version : Solved: option box, combo box and excel



whitewidow
02-11-2007, 05:18 PM
a bit of a problem, i have all my data on excel and on VBA form i have 4 option buttons in one frame, in the other frame i have one combo box and two text box.

in my excel work i have Property Id field, bedroom field, Price field, and Description Field.

when a user selects option one then the combo box should display all Property ID for that option box, if user selects option box two then it should display all property Id for that combo box.

example: option box one is two bedroom, option box two is 3 bedroom and so on.

so if i select option box one then the combo box should display property Id for two bedroom.

how can i do this, is there any example that i can look at becuase i am having trouble with getting VBA to read data from excel.

Simon Lloyd
02-12-2007, 12:57 AM
Whitewidow post your workbook that you have so far or an example so we can see what you are trying to achieve, this way you're sure to get the help you need!

Regards,
Simon

whitewidow
02-12-2007, 01:07 AM
i forgot to mention that i have a form for house and a form for flats so there is a worksheet for houses and a worksheet for flats.

here is what i have so far for the House form, but when i change worksheet to flats then code uses flats data.

Private Sub ophfive_Click()
cmbhid.RowSource = "a24:a30"
End Sub

Private Sub ophfour_Click()
cmbhid.RowSource = "a17:a23"
End Sub

Private Sub ophthree_Click()
cmbhid.RowSource = "a10:a16"
End Sub

Private Sub ophtwo_Click()
cmbhid.RowSource = "a3:a9"
End Sub

what do i need to do to so the data is collected from worksheet houses.

Charlize
02-12-2007, 05:47 AM
To get you started (a possible way) ... You need to change the sheets when using rowsource (My guess).

Charlize

whitewidow
02-12-2007, 12:37 PM
this example that has been posted is for a list box, but i have my coding for OPtion box.

i have a main menu and in main menu i have two option box. one option box is for house and the other option box is for flats.

when i select option box house then a form appears with house details, but when i select flats then another form appears and the details of form appears.

i am stuck on this coding.

whitewidow
02-12-2007, 12:37 PM
this example that has been posted is for a list box, but i have my coding for OPtion box.

i have a main menu and in main menu i have two option box. one option box is for house and the other option box is for flats.

when i select option box house then a form appears with house details, but when i select flats then another form appears and the details of form appears.

i am stuck on this coding.

Charlize
02-12-2007, 12:53 PM
this example that has been posted is for a list box, but i have my coding for OPtion box.

i have a main menu and in main menu i have two option box. one option box is for house and the other option box is for flats.

when i select option box house then a form appears with house details, but when i select flats then another form appears and the details of form appears.

i am stuck on this coding.Where is your file so we can see what you are trying to do ... I want to help but I'm not going to replicate your setup (because it would probably be some wild guessing). I showed you with the listbox the idea behind the selection of the sheets. Probably the optionbox is something similar qua coding ...

Charlize

whitewidow
02-12-2007, 01:34 PM
here is the attachment of my file.

the welcome screen is the first form.

Charlize
02-12-2007, 03:38 PM
A little bit modified to read values for flat or house. Try the one with flat. When selecting value in combobox, values of textboxes change accordingly.

Charlize

ps. Instead of the find-routine that I used You could use the vlookup function. But I haven't had enough time to look at it. I had a minor problem with it. So application.worksheetfunction.vlookup(value to look for,tabelmatrix,columnno) . But there was some problem with it. Maybe I'll find it a little bit later.

whitewidow
02-12-2007, 03:51 PM
A little bit modified to read values for flat or house. Try the one with flat. When selecting value in combobox, values of textboxes change accordingly.

Charlize

thank you very much Charlize, how do i get the description to be the in next paragraph, so the user can see all the sentence.

whitewidow
02-12-2007, 05:13 PM
Charlize thank you very much, i have figured out how to do multiline in textbox