WithEvents Form AccessObject ... conundrum

bobsan42

Well-known Member
Joined
Jul 14, 2010
Messages
1,364
Hello all.
My goal at the moment is: To open Form1 as background, make it translucent, then use the openArgs to pass a name to open Form2 on top of it. When Form2 is closed Form1 to close automatically.
I achieved it easily with DoCmd.OpenForm but then I have to set WindowMode:=acDialog, which shows the form titlebar and ruins the design.
So I am trying to make it in another way. After some time I got to the idea to declare (in the module of Form1) a form object withEvents, assign Form2 to it, open it and when it is closed it will close Form1.
So far the problem is:
Case 1: I get a Type mismatch error on the line Set frm = ....
VBA Code:
Private WithEvents frm As Access.Form
...
Set frm = CurrentProject.AllForms(Me.OpenArgs)
frm.Close = "[Event Procedure]"
DoCmd.OpenForm frm.Name
...
Case 2: When I try this - The compiler just says Compile error: Object does not source automation events
VBA Code:
Private WithEvents frm As AccessObject
It does not accept Variant or Object at all on this line.

Any workarounds, or better ideas than mine are welcome?
Thanks in advance.
 

bobsan42

Well-known Member
Joined
Jul 14, 2010
Messages
1,364
Yes it works. It took some adjusting because it was for excel and didnot initially work in access.
I'll be careful with the API's.
;)
Cheers.
 

Some videos you may like

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Watch MrExcel Video

Forum statistics

Threads
1,127,758
Messages
5,626,686
Members
416,200
Latest member
Pulsar3000

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
Top