Results 1 to 11 of 11
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919

    How to cause a form event to fire from a general module

    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.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    You can use the Public keyword to make the procedure Public vs. Private.

    This is the simple answer.

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    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.

  4. #4
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,389
    You have to use this format:

    Code:
    Call Form_frmMyForm.TheProcedure

  5. #5
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    I was able to get it to work this way ...
    CurrentDb.Execute Forms!Form1.cmdExecute_Click

    .
    Attached Files Attached Files

  7. #7
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    And the winner is!!!

    #4
    Code:
    Call Form_frmRegister.PositionToBottom
    Thanks everyone.

  8. #8
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    I didn't even see post #4 until now. I was trying to remember how to call it.

  9. #9
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    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

  10. #10
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,389
    #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.

  11. #11
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    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.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Combo Box On Click Event does not fire
    By GraeagleBill in forum Forms
    Replies: 7
    Last Post: 10-30-2015, 01:20 PM
  2. Fire off event on another form
    By Ruegen in forum Access
    Replies: 4
    Last Post: 04-12-2015, 11:50 PM
  3. Replies: 11
    Last Post: 11-13-2014, 08:52 PM
  4. Replies: 5
    Last Post: 12-03-2013, 01:25 PM
  5. Trying to fire event on record change
    By danielhowden in forum Forms
    Replies: 3
    Last Post: 05-13-2011, 06:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums