Link to home
Start Free TrialLog in
Avatar of spacebaby
spacebaby

asked on

Why is this causing an error? DoCmd.OpenForm and Load methods

I'm trying to open a popup form using VBA and neither the Load or DoCmd options are working:

DoCmd.OpenForm (Form_sfrmSoftwareFailurePopup) <--Says that the argument is the wrong data type.  This is the name of my form in the VBA project Explorer Window.

Load (Form_sfrmSoftwareFailurePopup) <-- Just says I can't load this object.

ASKER CERTIFIED SOLUTION
Avatar of 1William
1William

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
DoCmd.OpenForm "sfrmSoftwareFailurePopup",,,,,acDialog

OR


rather than the Load approach, try it this way:

Dim MyForm as Form_sfrmSoftwareFailurePopup
Set MyForm = New Form_sfrmSoftwareFailurePopup

MyForm.Visible = True

if you have made the form's Modal Property to True, then the form will open as a FDIALOG, requiring the user to respond to THAT form, before going on.

AW
What version of access are you using?

go to the database window and click on the form, press F2 to rename it and then CTRL-C to copy the form name.

In your code you need to do
DoCmd.OpenForm "FormName"

and I suspect you are confucing the Form_ with a feature in VBA that you can reference a form and if the form is not open then it will be opened. This is for example sets the visible property to true in the form sfrmSoftwareFailurePopup and if the form is not open then open it and set the visible property to true.

Form_sfrmSoftwareFailurePopup.visible = True

HTH Andrew