A
aarrgghh765
Hi,
I have a problem with some code I'm trying to write. The idea was to
have a value passed in to a sub and use Select Case to perform an
action based on the Case.
i.e. I have;
dim sfrm as subform
dim ctl as control
set sfrm = me.controls("Containers Subform")
select case strPassedValue
Case "Value1"
for each ctl in sfrm.controls
'do stuff
next
Case "Value2"
for each ctl in sfrm.controls
'do stuff
next
end select
When the code hits the line below Case "Value2" I get the error message
"Duplicate declaration in current scope". It looks like the Case
statements aren't seperate code blocks as I thought they were, so
casting ctl more than once won't work.
While writing this out I suppose I could send the code into a Sub which
might solve the problem, I did try a "set ctl = null" statement just
prior to the Case "Value2" line but that didn't work.
Any other ideas on how I might get round this or a better approach?
I have a problem with some code I'm trying to write. The idea was to
have a value passed in to a sub and use Select Case to perform an
action based on the Case.
i.e. I have;
dim sfrm as subform
dim ctl as control
set sfrm = me.controls("Containers Subform")
select case strPassedValue
Case "Value1"
for each ctl in sfrm.controls
'do stuff
next
Case "Value2"
for each ctl in sfrm.controls
'do stuff
next
end select
When the code hits the line below Case "Value2" I get the error message
"Duplicate declaration in current scope". It looks like the Case
statements aren't seperate code blocks as I thought they were, so
casting ctl more than once won't work.
While writing this out I suppose I could send the code into a Sub which
might solve the problem, I did try a "set ctl = null" statement just
prior to the Case "Value2" line but that didn't work.
Any other ideas on how I might get round this or a better approach?