Is there a way to cause a form event to fire triggered from a general module? Like trigger "On Before Render" from a general module. What I want to do is run a Sub in the continuous form's module that performs record positioning following a Requery.
Is there a way to cause a form event to fire triggered from a general module? Like trigger "On Before Render" from a general module. What I want to do is run a Sub in the continuous form's module that performs record positioning following a Requery.
You can use the Public keyword to make the procedure Public vs. Private.
This is the simple answer.
That's what I started with. I made the Sub of interest Public. I made sure the form of interest was open and that it had the focus but when I attempted to call the Public Sub from the general module "Access compile" complained that it couldn't find it.
You have to use this format:
Code:Call Form_frmMyForm.TheProcedure
Did you try something long this:
Call yourEventName
see this for more info
I was able to get it to work this way ...
CurrentDb.Execute Forms!Form1.cmdExecute_Click
.
And the winner is!!!
#4
Thanks everyone.Code:Call Form_frmRegister.PositionToBottom
I didn't even see post #4 until now. I was trying to remember how to call it.
And it has to have the "Form_" prefix and NOT "Forms!". If one tries that latter the code won't even compile. If one leaves the "Form_" prefix off, i.e., Call FormName.ProcedureName, execution will bomb for lack of object expression.
Bill
#4
Yeah, I moved a lot of procedures from behind the form to a module before I discovered this by trial and error a few years ago. Works great.
IIRC, what that does (Form_) is creates another instance of the Form Object. So, that might not be what you are expecting if you want code to consider, for instance, a certain form's recordset. I would suggest testing.