Results 1 to 11 of 11
  1. #1
    newaccess is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    May 2010
    Posts
    33

    Arrow how to trigger a button event at same form

    I use MS access 2007 at window xp.
    I would like to be able to trigger the "on click event" of a ADD button WHEN FORM OPEN ( ON FORM OPEN ENEVT)
    I also able to trigger the "on click event" of a ADD button when I clicked Save button at same form.

    Thanks for help!

    new access

  2. #2
    mcktigger is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2011
    Posts
    19
    Can you explain a bit more what you mean?

    Do you want the button to be clicked by the user or do you want the button to do something automatically when the form opens. If you want the button to do something automatically then why not just code the On Load event of the form to do xyz rather than trigger the on click event.

    Same for the Save button why not just program the on click event of the save button to do what you want the add button to do.

    I'm not quite understanding what you're trying to do so maybe you can explain a bit more.

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    You can call any event subprocedure just as you would any sub or function. Example: Call btnExecute_Click
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    newaccess is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    May 2010
    Posts
    33
    I copy your command to form open event as
    Private Sub Form_Open(Cancel As Integer)
    Call ADD_Click
    End Sub
    But I get message as
    compile error: sub or function not defined

    Any suggestion?
    I use MS access 2007in window 7

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I think the OPEN event is too soon. Try the LOAD event

    From Help:
    When you first open a form, the following events occur in this order:

    Open > Load > Resize > Activate > Current


    The Open event occurs when a form is opened, but before the first record is displayed

    The Load event occurs when a form is opened and its records are displayed.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    No idea why that error except maybe can't use in Open event. My example is code in a combobox AfterUpdate event.

    You want form to open to new record but still have existing records viewable?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    newaccess is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    May 2010
    Posts
    33
    Hi Movice,

    Could you put some example of trigger a add button event at access form open?
    I am still fight this issue.

    I am using access 2005 in window XP

    Thanks

    Jimmy

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    What do you really want to do? Do you want form to move to new record immediately after opening?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    I, too, would have guessed that Form_Open was too early for this to work, but testing, using the Form_Open event to call the OnClick event of Command Button whose code is

    DoCmd.GoToRecord , , acNewRec

    works quite well. Are you absolutely positive the button was named ADD? Is this code in the Code Module behind the Form the button resides on? I assume that the button, when clicked, works; is this true?

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  10. #10
    newaccess is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    May 2010
    Posts
    33
    Dear Missingling,

    Thanks for your help!! It works.

    newaccess

  11. #11
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Glad we could help!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Trigger event with button click
    By AMAS in forum Forms
    Replies: 8
    Last Post: 06-07-2012, 09:42 AM
  2. event to trigger after new record
    By richlyn in forum Access
    Replies: 1
    Last Post: 03-02-2012, 10:26 AM
  3. Replies: 2
    Last Post: 07-24-2011, 08:50 PM
  4. Trigger subform event
    By tuna in forum Forms
    Replies: 0
    Last Post: 05-09-2010, 06:29 AM
  5. Replies: 0
    Last Post: 03-11-2010, 02:11 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