G
Guest
Guest
Hi-
I designed a project with about 24 userforms. Most of them assign a value to a spreadsheet. The others are for the purpose of selecting a choice to show another userform(By way of a module). Im using optionbutton controlls for these few. Heres the code for one of them:
Sub CommandButton3_Click()
'On Error Resume Next
If OptionButton1.Value = True Then Me.Hide
If OptionButton1.Value = True Then Call Module1.sheet1
'On Error GoTo 0
'On Error Resume Next
If OptionButton2.Value = True Then Me.Hide
If OptionButton2.Value = True Then Call Module1.sheet2
'On Error GoTo 0
'On Error Resume Next
If OptionButton3.Value = True Then Me.Hide
If OptionButton3.Value = True Then Call Module1.sheet3
'On Error GoTo 0
'On Error Resume Next
If OptionButton4.Value = True Then Me.Hide
If OptionButton4.Value = True Then Call Module1.sheet4
'On Error GoTo 0
Unload Me
End Sub
Heres the problem- when a certian sequence of userforms are promped to be shown or unloaded, the userforms with the optionbuttons hid and unload initialy, but come back (show) at some other point! If I dont use the error method, I get an error during the sequence, using the error method, the form just reappears. Ive tried everthing to pinpoint the problem. I replaced the optionbutton with a commandbutton to see the results and it works as it should. When I went back to using the optionbutton, I got an error. Im convinced its the way I wrote the code for the optionbuttons, but im not sure how to correct it- please help??
--------------------------------------------------------------------------------
Jack in the UK
Board Master
Joined: Feb 17, 2002
Posts: 153
From: South London (Streatham / Brixton)
Posted: 2002-03-10 15:31
--------------------------------------------------------------------------------
Hi
Try:
Unload MyUserForm
try after each not just at end so will act as kill.
_________________
Good Luck
HTH
Rdgs
==========
Jack in the UK
--------------------------------------------------------------------------------
Anonymous
Unregistered User Posted: 2002-03-10 15:55
--------------------------------------------------------------------------------
Still doesnt work.
Sub CommandButton3_Click()
Me.Hide
'On Error Resume Next
'If OptionButton1.Value = True Then Me.Hide
If OptionButton1.Value = True Then Call Module1.sheet1
Unload Me
'On Error GoTo 0
'On Error Resume Next
'If OptionButton2.Value = True Then Me.Hide
If OptionButton2.Value = True Then Call Module1.sheet2
Unload Me
'On Error GoTo 0
'On Error Resume Next
'If OptionButton3.Value = True Then Me.Hide
If OptionButton3.Value = True Then Call Module1.sheet3
Unload Me
'On Error GoTo 0
'On Error Resume Next
'If OptionButton4.Value = True Then Me.Hide
If OptionButton4.Value = True Then Call Module1.sheet4
Unload Me
'On Error GoTo 0
Unload Me
End Sub
Any other sugestions?????
I designed a project with about 24 userforms. Most of them assign a value to a spreadsheet. The others are for the purpose of selecting a choice to show another userform(By way of a module). Im using optionbutton controlls for these few. Heres the code for one of them:
Sub CommandButton3_Click()
'On Error Resume Next
If OptionButton1.Value = True Then Me.Hide
If OptionButton1.Value = True Then Call Module1.sheet1
'On Error GoTo 0
'On Error Resume Next
If OptionButton2.Value = True Then Me.Hide
If OptionButton2.Value = True Then Call Module1.sheet2
'On Error GoTo 0
'On Error Resume Next
If OptionButton3.Value = True Then Me.Hide
If OptionButton3.Value = True Then Call Module1.sheet3
'On Error GoTo 0
'On Error Resume Next
If OptionButton4.Value = True Then Me.Hide
If OptionButton4.Value = True Then Call Module1.sheet4
'On Error GoTo 0
Unload Me
End Sub
Heres the problem- when a certian sequence of userforms are promped to be shown or unloaded, the userforms with the optionbuttons hid and unload initialy, but come back (show) at some other point! If I dont use the error method, I get an error during the sequence, using the error method, the form just reappears. Ive tried everthing to pinpoint the problem. I replaced the optionbutton with a commandbutton to see the results and it works as it should. When I went back to using the optionbutton, I got an error. Im convinced its the way I wrote the code for the optionbuttons, but im not sure how to correct it- please help??
--------------------------------------------------------------------------------
Jack in the UK
Board Master
Joined: Feb 17, 2002
Posts: 153
From: South London (Streatham / Brixton)
Posted: 2002-03-10 15:31
--------------------------------------------------------------------------------
Hi
Try:
Unload MyUserForm
try after each not just at end so will act as kill.
_________________
Good Luck
HTH
Rdgs
==========
Jack in the UK
--------------------------------------------------------------------------------
Anonymous
Unregistered User Posted: 2002-03-10 15:55
--------------------------------------------------------------------------------
Still doesnt work.
Sub CommandButton3_Click()
Me.Hide
'On Error Resume Next
'If OptionButton1.Value = True Then Me.Hide
If OptionButton1.Value = True Then Call Module1.sheet1
Unload Me
'On Error GoTo 0
'On Error Resume Next
'If OptionButton2.Value = True Then Me.Hide
If OptionButton2.Value = True Then Call Module1.sheet2
Unload Me
'On Error GoTo 0
'On Error Resume Next
'If OptionButton3.Value = True Then Me.Hide
If OptionButton3.Value = True Then Call Module1.sheet3
Unload Me
'On Error GoTo 0
'On Error Resume Next
'If OptionButton4.Value = True Then Me.Hide
If OptionButton4.Value = True Then Call Module1.sheet4
Unload Me
'On Error GoTo 0
Unload Me
End Sub
Any other sugestions?????