|
-
Apr 24th, 2000, 08:04 PM
#1
Thread Starter
New Member
hey,
I try to make a form in Access2000 with 20 optionbuttons.
When the form load, i try to hide a copple of optionbuttons.
Houw can i make all of the buttons a index
the caption of the buttons is "optanswer" and a number after the caption.
when there is in a tabel the value "4" then the first 4 optionbuttons may be visible, the rest must be hide.
when there is in a tabel the value "6" the 6 first option buttons may be visible, the rest must be hide.
Help, help and .............
I just a beginning vb user so, if it is possible, the full source code please.
caption optionbuttons :
button1 ---> optAnswer1
button2 ---> optAnswer2
Ets, ets,....
cellname in tabel "testtbl" with the value of the buttons = "testaantal"
Best Regards
[Edited by expodium on 04-25-2000 at 09:12 AM]
-
Apr 24th, 2000, 08:36 PM
#2
Fanatic Member
Control Array
First off we need all of these buttons to be in a control array. That is they will all have the same name, but you access individual buttons using an index.
e.g.
Code:
myOptionButton(1).Visible = True
myOptionButton(2).Visible = True
'...
myOptionButton(20).Visible = True
To do this create one option button on a form. Then copy this and paste it 19 times. This will give you 20 option buttons. If you want the index to start from 1 rather than zero you will have to change each of the indexes. Otherwise they will be 0 - 19, rather than 1 - 20.
Now we have a control array we can easily hide or show any buttons.
If all of the option buttons are hidden to start with then to show 4 option buttons you would do this
Code:
'myNum = the value you get from your Access Table
myNum = valueInTable
For i = 1 To myNum
myOptionButton(i).Visible = True
'set the caption of the button
myOptionButton(i).Caption = "optAnswer" & i
Next i
or if the option buttons aren't hidden to start with then you should do
Code:
'myNum = the value you get from your Access Table
myNum = valueInTable
For i = 1 To myNum
myOptionButton(i).Visible = True
'set the caption of the button
myOptionButton(i).Caption = "optAnswer" & i
Next i
For i = (myNum + 1) To 20
myOptionButton(i).Visible = False
Next i
Hope this helps.
[Edited by Iain17 on 04-25-2000 at 02:36 PM]
Iain, thats with an i by the way!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|