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_sfrmSoftwareFailureP opup) <--Says that the argument is the wrong data type. This is the name of my form in the VBA project Explorer Window.
Load (Form_sfrmSoftwareFailureP opup) <-- Just says I can't load this object.
DoCmd.OpenForm (Form_sfrmSoftwareFailureP
Load (Form_sfrmSoftwareFailureP
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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_sfrmSoftwareFailurePo pup.visibl e = True
HTH Andrew
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_sfrmSoftwareFailurePo
HTH Andrew
OR
rather than the Load approach, try it this way:
Dim MyForm as Form_sfrmSoftwareFailurePo
Set MyForm = New Form_sfrmSoftwareFailurePo
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