Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    MadTom's Avatar
    MadTom is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Location
    CT and VT
    Posts
    206

    Need to know what Event to use?

    I have a Search form that finds a record and when I return to the main form I need to run a Sub to update some list boxes. Tried many Events and can't get it to work. I know the Sub works because I can use a test button to run Sub.
    Thanks,


    Tom

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    How about the activate event of the form, or the close event of the search form?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    MadTom's Avatar
    MadTom is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Location
    CT and VT
    Posts
    206
    Can I run a Sub for the Main form on a close of the Search form? I did try
    activate event.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    You should be able to if you make it public.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    MadTom's Avatar
    MadTom is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Location
    CT and VT
    Posts
    206
    Ok, that makes sense! Thanks!

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    No problem, post back if you get stuck.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    MadTom's Avatar
    MadTom is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Location
    CT and VT
    Posts
    206
    I've been researching Modules and Public Subs. I quess I need to a standard Modules to make it Public. Now if I have calls in my Sub, I would guess they would have to be in the Module too. It there any good web pages on changing a Sub to a Public Module?
    Thanks!

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    It can but doesn't need to be. I just tested a button on a form, changing it from Private to Public:

    Public Sub Command3_Click()

    Then I called that button's code from another button:

    Code:
    Private Sub Command22_Click()
      Command3_Click
    End Sub
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    MadTom's Avatar
    MadTom is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Location
    CT and VT
    Posts
    206
    I want to run the Sub in form1 when I close form2. If I change it to Public I get "Sub not defined".

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    You'd need the full reference from another form, like:

    Forms!form1.Command3_Click
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    MadTom's Avatar
    MadTom is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Location
    CT and VT
    Posts
    206
    I tried Forms!frmSearch.CheckValue. I need this to work in the Search form on closing. Do I need a Module? or Public Sub?
    Private Sub Form_Close()
    Call CheckValue

    End Sub

  12. #12
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    The sub being called needs to be public. Say it's in form1. The sub you want to call in form1 is Command3_Click.
    From another form the syntax to run that command (form1 must be loaded, of course)
    Call Form_form1.Command3_Click

    Use that exact format. Prefix is FORM_ not FORMS!

  13. #13
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    I'll get out of the way. What I posted was tested and did work.

    Forms!form1.Command3_Click
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  14. #14
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    I'll get out of the way.
    Paul, didn't mean to come across as critical. Just stating what I have used for years that works for me.

  15. #15
    MadTom's Avatar
    MadTom is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Location
    CT and VT
    Posts
    206
    Sorry, something I'm not getting.

    Code in frmSearch
    Code:
    Private Sub Form_Close()    'Code to run on close
       Form!frmParts.CheckValue
    End Sub
    Code in frmParts
    Code:
    Public Sub CheckValue()            'Case Select to remove Text
        On Error Resume Next
        Select Case Me.cboType.Value
        Case "Capacitor"
            Call addtext
        Case "Resistor"
            Call removetext
        Case "Diode"
            Call removetext
        Case "Transistor"
            Call removetext
        Case "IC"
            Call removetext
        Case "Hardware"
            Call removetext
        Case "Misc"
            Call removetext
        Case "Board"
            Call removetext
        Case Else
            Call cmdLast_Click
            'Call removetext
        End Select
    End Sub

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Key Press Event and/or Key Up Event not firing as expected
    By GraeagleBill in forum Programming
    Replies: 7
    Last Post: 01-16-2018, 04:11 AM
  2. Replies: 2
    Last Post: 10-09-2016, 05:41 PM
  3. Replies: 7
    Last Post: 05-08-2014, 10:34 AM
  4. Replies: 1
    Last Post: 03-29-2014, 07:46 PM
  5. Replies: 3
    Last Post: 05-07-2012, 12:17 PM

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