W
Webtechie
Hello,
I am finding that I have the same code for different forms. The way our
shop needs the forms, we have one form that has a some data. Then another
form with the same data and more controls and more data.
I want to be able to write code that will work on either form.
sub ProcessResults(byRef userChoice as integer)
Dim myFrm1 as userform1
Dim myFrm2 as userform2
Dim myFrm
'Set the form variables
'******************
if userChoice = 1 then
set myFrm 1 = NEW userform1
set myFrm = myFrm1
else
set myFrm2 = NEW userform2
set myFrm = myFrm2
end if
'Now reference the form fields
'**************************
myFrm.txtFirstName.text = "David"
.... and so on
I can't seem to be able to set myFrm to whichever form is needed based on
userChoice and the if Statement.
I'm using Excel 2007.
Does anyone know how to set a variable for userform such as I've written
above?
Thanks.
Tony
I am finding that I have the same code for different forms. The way our
shop needs the forms, we have one form that has a some data. Then another
form with the same data and more controls and more data.
I want to be able to write code that will work on either form.
sub ProcessResults(byRef userChoice as integer)
Dim myFrm1 as userform1
Dim myFrm2 as userform2
Dim myFrm
'Set the form variables
'******************
if userChoice = 1 then
set myFrm 1 = NEW userform1
set myFrm = myFrm1
else
set myFrm2 = NEW userform2
set myFrm = myFrm2
end if
'Now reference the form fields
'**************************
myFrm.txtFirstName.text = "David"
.... and so on
I can't seem to be able to set myFrm to whichever form is needed based on
userChoice and the if Statement.
I'm using Excel 2007.
Does anyone know how to set a variable for userform such as I've written
above?
Thanks.
Tony