This code has been working fine until now??

Darren Smith

Well-known Member
Joined
Nov 23, 2020
Messages
631
Office Version
  1. 2019
Platform
  1. Windows
Morning All

This Toggle Switch code has been working fine until now.
Now the error message says
Run-time error 401
Can`t show non-modal form when modal form is displayed
How do I overcome this

VBA Code:
Private Sub Parts_Form_Click()


If Me.Parts_Form.Value = True Then

Jobcard_Parts.Show False

        Me.Width = 225
        Me.Height = 60
        Me.Parts_Form.Top = 0
        Me.Parts_Form.Left = 0
        Me.Parts_Form.Caption = "Close Parts Form"
        Me.Top = 700
        Me.Left = 0
Else

Jobcard_Parts.Hide

Body_And_Vehicle_Type_Form.Show False

        Me.Width = 1013
        Me.Height = 630
        Me.Parts_Form.Top = 450
        Me.Parts_Form.Left = 10
        Me.Parts_Form.Caption = "Open Parts Form"
        Me.Top = 0
        Me.Left = 300
End If

End Sub
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
do you have another userform open at the same time. this occurs when you try to mix modal and nonmodal userforms
 
Upvote 0
now i check, this form is still loaded
Jobcard_Parts.Hide
hide is still loaded. if you dont need to be able to switch between both userforms at once, than set them both to ShowModal = True
 
Upvote 0
Hello Daren,
if you are set default both show modal values to false,
then try when calling both userforms show without "False".
VBA Code:
If Me.Parts_Form.Value = True Then
        Jobcard_Parts.Show
VBA Code:
Else
        Body_And_Vehicle_Type_Form.Show
 
Upvote 0
another option may be to incorporate the 2 userforms in 1 by using frames. i find this a useful way of not having to deal with passing variables between userforms also
 
Upvote 0

Forum statistics

Threads
1,215,375
Messages
6,124,581
Members
449,174
Latest member
chandan4057

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top