Originally Posted by
davegri
For the nested Select Case approach I was envisioning something like this: (thing is your existing object name)
Code:
Select case thing
Case "cboProcess", "lblProcess"
.Width = TempNProcWidth
.Left = TempProcLeft
Select case thing
case "cboProcess"
.Top = top3Ctl 'or Case1 or Case(1)
case else
.Top = top3Lbl
end select
end select
Isn't this basically the same as the IIf I already have?
Code:
.Top = IIf(.Name = "cboProcess", top3Ctl, top3Lbl)
Case cbo^ Case else^
I understand the Select Case would allow me to do more than 1 case but I am just using the Switch function in that case.
This wasn't my question though.
The select case is in a for loop that loops through the controls.
My case statements have 2 expressions.
Expression 1 "cboProcess"
Expression 2 "lblProcess"
I want to know if inside the select statement there is a way to check if Expression 1 is true regardless of the string name.
aka a string of code that I could copy to all the cases.
Here is a larger segment of the code so people can understand what I mean better.
Code:
Case "cboProcess", "lblProcess"
.Width = TempNProcWidth
.Left = TempProcLeft
.Top = IIf(.Name = "cboProcess", top3Ctl, top3Lbl)
Case "txtIdMax", "lblIdMax"
.Width = MinMaxWidth
.Left = LeftEdge
.Top = IIf(.Name = "txtIdMax", top3Ctl, top3Lbl)
Case "txtIdMin", "lblIdMin"
.Width = MinMaxWidth
.Left = MinLeft
.Top = IIf(.Name = "txtIdMin", top3Ctl, top3Lbl)
See how each IIf I have to type out the 1st expression (cboProcess, txtIdMax, txtIdMin).
I am looking to see if there is a way that I can just say "If .Name = expression1" as if the case expressions were an array.
So instead my code could look like this:
Code:
Case "cboProcess", "lblProcess"
.Width = TempNProcWidth
.Left = TempProcLeft
.Top = IIf(.Name = Me.Expression1, top3Ctl, top3Lbl)
Case "txtIdMax", "lblIdMax"
.Width = MinMaxWidth
.Left = LeftEdge
.Top = IIf(.Name = Me.Expression1, top3Ctl, top3Lbl)
Case "txtIdMin", "lblIdMin"
.Width = MinMaxWidth
.Left = MinLeft
.Top = IIf(.Name = Me.Expression1, top3Ctl, top3Lbl)
P.S. Apologies if any of that came off as rude its not my intention.