VB help

Recommended Videos

Zombie_Fish

Opiner of Mottos
Mar 20, 2009
4,584
0
0
Warning: I haven't used VB in a while so I may be a bit off with analysing your code.

iphonerose said:
I want to be able to limit the options in the Book From month drop down box based on what the user selects in the book from date drop down box. (i.e. if a user selects 30 in the date drop down box, I don?t want 2 (feb) to appear as an option in the month drop down box and similarly with 31 and relevant months).
At the minute if I select 31, the options in the month from box are right but if I select 30, I get all months. If any of ye have the time I?d appreciate some help with where I?m going wrong.
Are you sure you're getting all the months when you select 30? If 2 is the only one that isn't meant to appear in the dropbox then you may have simply not noticed it missing. That is all I can really think with that problem since your code seems fine.

Also I was wondering if there is a way to clear the month box every time I select a new date? For example at the minute, if I select 31, I get the options: 1, 3, 5, 7, 8, 10, 12 and then if I change the selection to 14 for example and I then click the dropdown for month I have: 1, 3, 5, 7, 8, 10, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12.
I think dropboxes have a function which clears the box of any current cells -- something like BF_month_bx.Items.Clear() for your code -- so try implementing that at the start of the procedure. VB certainly provides such a function for listboxes as I've just checked my old VB work for such a function, so I'd be surprised if they didn't provide the same for dropboxes.
 

iphonerose

New member
May 20, 2011
365
0
0
Mortai Gravesend said:
iphonerose said:
Got it working :)
Curious, where did you have to put the line that clears things?
I put it in where you said, when I fixed my other problem (the main problem) then the clear function worked too.
To fix my first problem all I had to do was get rid of the Asc()'s..as in..
Instead of:
If Asc(BF_date_bx.SelectedIndex) = Asc(31), I just had to type If BF_date_bx.SelectedItem = 31 and so on..