Results 1 to 5 of 5
  1. #1
    JimO is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Dec 2015
    Posts
    126

    Combine the action of 2 buttons into 1 operation

    The first button opens a form,

    Code:
    Private Sub Command188_Click()
        DoCmd.OpenForm "SportsMBLFrm", acNormal
    End Sub
    The second preforms a filter,



    Code:
    Private Sub InProgress_Click()
        Me.Filter = "[Progress] Is Not Null"
        Me.FilterOn = True
        Me.Caption = "Games in Progress"
        Me.lblSort.Caption = "Games Underway"
    End Sub
    Looking to combine into a single operation to open the form in the filtered configuration.

    Not having any luck.

    Jim O

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    The keyword "Me" is shorthand to refer to the form you currently are on. To refer to another form, you must use the fully qualified syntax.

    Try
    Code:
    Private Sub Command188_Click()   ' "Command188" is a poor name.... I'm just sayin.........
        DoCmd.OpenForm "frmPatientDoc"  ', acNormal  <<---  acNormal is the default, so it is not needed
        Forms!SportsMBLFrm.Filter = "[Progress] Is Not Null"
        Forms!SportsMBLFrm.FilterOn = True
        Forms!SportsMBLFrm.Caption = "Games in Progress"
        Forms!SportsMBLFrm.lblSort.Caption = "Games Underway"
    End Sub

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    assuming both buttons on the same form, why not

    Private Sub Command188_Click()
    DoCmd.OpenForm "SportsMBLFrm", acNormal,,"[Progress] Is Not Null"
    forms!SportsMBLFrm.Caption = "Games in Progress"
    forms!SportsMBLFrm.lblSort.Caption = "Games Underway"
    End

  4. #4
    JimO is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Dec 2015
    Posts
    126
    Thank you for the help. That works as hoped.

    Suggestions noted as well.

    Thanks
    Jim O

  5. #5
    JimO is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Dec 2015
    Posts
    126
    The buttons are not on the same form so ssanfu's solution works best but thanks for the input.

    Jim O

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

Similar Threads

  1. Action on Form Buttons
    By Lou_Reed in forum Access
    Replies: 5
    Last Post: 07-22-2015, 12:27 PM
  2. Replies: 1
    Last Post: 08-15-2013, 08:12 PM
  3. Replies: 3
    Last Post: 05-22-2013, 06:24 PM
  4. Replies: 10
    Last Post: 09-18-2012, 02:00 PM
  5. Form Operation
    By glen in forum Forms
    Replies: 5
    Last Post: 09-13-2012, 11:41 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