How can this be simplified?

G

Guest

I have two option groups. Frame1 has option values of 1,2,3. Frame has
values of 10,20,30. Clicking in Frame 2 runs code based on what was
previously clicked in Frame1. My code looks like this, which is easy to
understand, but I am trying to keep things clean and simple. I'd appreciate
guidance on what alternatives would work. Thanks in advance.

Private Sub Frame2_Click()
Select Case Me.Frame2
Case 10
Select Case Me.Frame1
Case 1
'Do 10+1 here.
Case 2
'Do 10+2 here.
Case 3
'Do 10+3 here.
End Select
Case 20
Select Case Me.Frame1
Case 1
'Do 20+1 here.
Case 2
'Do 20+2 here.
Case 3
'Do 20+3 here.
End Select
Case 30
Select Case Me.Frame1
Case 1
'Do 30+1 here.
Case 2
'Do 30+2 here.
Case 3
'Do 30+3 here.
End Select
End Select
End Sub
 
G

Guest

David,

Your method should work fine; depending on what is in your options groups,
and what functionality you want to implement for the selections in the two
groups, there may be better ways, but without knowing the specifics, I cannot
give you much advice.

I frequently use option groups to help me refine SQL statements, in which
case my code looks more like below. I don't normally put this type of code
in the click event of OG2, because my user might click in OG2 and change it
before the change OG1, and you would then have to have the code in both
places. Having a command button to execute simplifies things.

Private Sub cmdExecute_Click()
Select Case Me.Frame2
Case 10
'Do 10
Case 20
'Do 2o
Case 30
'Do 30
End Select

Select Case Me.Frame1
Case 1
'Do 1 here.
Case 2
'Do 2 here.
Case 3
'Do 3 here.
End Select

End Sub

Dale
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top