开发者

To select optionbutton from the frames in VB

开发者 https://www.devze.com 2023-04-11 06:43 出处:网络
I\'ve used 4 optionbuttons in each frame on the from. Like wise i\'ve taken 10 frames on the form.. now i just want to store the value 开发者_Python百科of those optionbuttons from each frame in the MS

I've used 4 optionbuttons in each frame on the from. Like wise i've taken 10 frames on the form.. now i just want to store the value 开发者_Python百科of those optionbuttons from each frame in the MSaccess database.. So the result in the database will be 10 values of optionbuttons for each frame.. Please Help me out


Assuming your question is actually "How can I get the selected option button in a group", then you need to check each in turn. The very simplest is:

'Get the selected option from frame 1
If Frame1Option1.Value Then
  Value1 = 1
ElseIf Frame1Option2.Value Then
  Value1 = 2
ElseIf Frame1Option3.Value Then
  Value1 = 3
ElseIf Frame1Option4.Value Then
  Value1 = 4
End If

'Get the selected option from frame 2
If Frame2Option1.Value Then
  Value2 = 1
ElseIf Frame2Option2.Value Then
  Value2 = 2
ElseIf Frame2Option3.Value Then
  Value2 = 3
ElseIf Frame2Option4.Value Then
  Value2 = 4
End If

If you make them a control array in each frame, then you can simplify the code to something like:

Dim Index As Long

'Get the selected option from frame 1
For Index = Frame1Options.LBound To Frame1Options.UBound
  If Frame1Options(Index).Value Then Value1 = Index
Next

Setting them then becomes just as simple:

Frame1Options(Value1).Value = True
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号