August 4th, 2002, 12:11 AM
|
#1 (permalink)
| | Junior Member
Join Date: Jun 2002 Location: Papua New Guinea
Posts: 12
| Combo Boxes (Urgent Help required)
I'm still working on a database for my school library.
There are two combo boxes - Grade, Course.
The combo box Grade allows the operator to pick grades from 8 - 12.
The combo box Course allows the operator to pick four courses: A, B, C and D
All the grades (8,9,10,11,12) can do A or B
Only grade 10 can do C
Only grades 11 and 12 can do D
On my form when the operator chooses grade 8 from Grade, I want the combo box Course to only give the operator the options A and B NOT C or D.
Can someone pllllllllllllllllleeeeeeeeeasse help me...
shahzadsk |
| |
August 4th, 2002, 02:27 AM
|
#2 (permalink)
| | Ultimate Member
Join Date: Oct 2001
Posts: 21,019
|
hmmm
well.. when you change the value in a combo box it calls an event
comboxbox_change() event
You could put code in there that says
Case 'A'
Case 'B'
combograde.add "A"
combograde.add "B"
Case 'c'
combograde.add C
well you get the point
not the greatest code in the world IMO but it'd work  |
| |
August 4th, 2002, 04:32 AM
|
#3 (permalink)
| | Senior Member
Join Date: Oct 2001 Location: Alberta, Canada
Posts: 563
|
gettin late for me to do much right now, but maybe this will help somehow...
to delete an option, set it to null:
document.forms[0]. name_of_select_box.options[ index_of_option_to_delete] = null;
to add an option (adds it to the end of drpdown box):
document.forms[0]. name_of_select_box.options[document.forms[0]. name_of_select_box.options.length] = new Option(" text", " value");
came from here basically...
ciao!
edit: can also use document.forms[' form_name'] instead of document.forms[0], actually, I'd recommend it since it's safer, unless it's guaranteed to be only one form on the page...
Last edited by ^hyd^ : August 4th, 2002 at 04:34 AM.
|
| |
August 4th, 2002, 09:07 AM
|
#4 (permalink)
| | Junior Member
Join Date: Jun 2002 Location: Papua New Guinea
Posts: 12
|
I'll try them out.
Thanks.. |
| |
August 4th, 2002, 11:43 AM
|
#5 (permalink)
| | Ultimate Member
Join Date: Oct 2001
Posts: 21,019
|
hmm you never did specify what language you're working in  |
| |
August 5th, 2002, 12:29 AM
|
#6 (permalink)
| | Junior Member
Join Date: Jun 2002 Location: Papua New Guinea
Posts: 12
|
Sorry.. VB in Access 2000 |
| |
August 5th, 2002, 12:33 AM
|
#7 (permalink)
| | Junior Member
Join Date: Jun 2002 Location: Papua New Guinea
Posts: 12
|
Private Sub Grade_Click()
10: Course.AddItem "ACT"
Course.AddItem "IB"
Course.AddItem "IGCSE"
Course.AddItem "PNG"
Select Case (Grade)
Case "8"
Course.RemoveItem "IB"
Course.RemoveItem "IGCSE"
GoTo 10
Case "9"
Course.RemoveItem "IB"
Course.RemoveItem "IGCSE"
GoTo 10
Case "10"
Course.RemoveItem "IB"
GoTo 10
Case "11"
Course.RemoveItem "IGCSE"
GoTo 10
Case "12"
Course.RemoveItem "IGCSE"
GoTo 10
End Select
End Sub
I used this but since it's a continuous loop it uses 99% of CPU power |
| |
August 5th, 2002, 12:34 AM
|
#8 (permalink)
| | Junior Member
Join Date: Jun 2002 Location: Papua New Guinea
Posts: 12
|
So I tried this..
It works, but if I click on grade 10 and Igcse and then i click back on grade 8, it will accept grade 8 and IGCSE..which should not be accepted.. I want to run the code every second..
Private Sub Course_Click()
If Grade = "8" And Course = "IB" Then
GoTo 1
Else: GoTo 2
2: If Grade = "8" And Course = "IGCSE" Then
GoTo 1
Else: GoTo 3
3: If Grade = "9" And Course = "IB" Then
GoTo 1
Else: GoTo 4
4: If Grade = "9" And Course = "IGCSE" Then
GoTo 1
Else: GoTo 5
5: If Grade = "10" And Course = "IB" Then
MsgBox "Please select either ACT, IGCSE or PNG from the dropdown list."
Course = ""
GoTo 100
Else: GoTo 6
6: If Grade = "11" And Course = "IGCSE" Then
MsgBox "Please select ACT, IB or PNG from the dropdown list."
Course = ""
GoTo 100
Else: GoTo 7
7: If Grade = "12" And Course = "IGCSE" Then
MsgBox "Please select ACT, IB or PNG from the dropdown list."
Course = ""
GoTo 100
Else: GoTo 100
End If
End If
End If
End If
End If
End If
End If
1: MsgBox "Please choose either ACT or PNG from the dropdown list."
Course = ""
100: End Sub |
| | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | |
Posting Rules
| You may post new threads You may post replies You may not post attachments You may not edit your posts HTML code is Off | | | | Most Active Discussions | | | | | Recent Discussions  | | | | | |