WithEvents Form AccessObject ... conundrum

bobsan42

Well-known Member
Joined
Jul 14, 2010
Messages
2,114
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2013
Platform
  1. Windows
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.
 
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.
 
Upvote 0

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Forum statistics

Threads
1,223,869
Messages
6,175,087
Members
452,611
Latest member
bls2024

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