Results 1 to 3 of 3
  1. #1
    Soundhouse is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2018
    Posts
    9

    Is there a way to know which button opened a certain form?

    I have a single form that is opened via 2 different routes.

    Button 1 opens the form with all records displayed

    Button 2 opens the form with a filtered selection

    This is all fine and dandy and is exactly what I want. However there are some controls on the form that I want to disable if the route I choose is Button 2.



    Is there a way of identifying which button routed me to the form so that I can disable or keep enabled certain controls.

    Hope this makes sense guys, any assistance would be much appreciated.

  2. #2
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    You can use the OpenArgs property of the DoCmd.OpenForm to pass in a string that could identify the button used.

    Then in the form use If Me.OpenArgs = "String1" etc.

  3. #3
    Soundhouse is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2018
    Posts
    9
    Thank you for that tip Minty, that worked perfectly for what I needed.

    Here's what I did for anyone else with a similar problem....

    This is the code behind the source form button...


    If Not IsNull(Me.TransUniqueID.Value) Then
    'last argument of DoCmd uses OpenArg to pass Doc List button name for manipulation in target form
    DoCmd.OpenForm "frmDocumentList", acNormal, "", "[TransUniqueID]='" & Me.TransUniqueID & "'", , , Me.cmdDocList.Name
    End If

    This is the code in the OnLoad event picking up the OpenArg property to allow me to hide certain controls dependent

    'hide / display controls depending on where Doc List form is opened from
    'if source OpenArgs property contains source button name, hide certain controls otherwise hide certain other controls if OpenArg is empty
    If Not IsNull(Me.OpenArgs) Then
    'hide controls if source button pressed from TransHdr form
    Me.CmbDiscFill.Visible = False
    Me.cmdFillDisc.Visible = False
    Me.CmbRFIFill.Visible = False
    Me.CmdFillRFI.Visible = False
    Me.CmbTIREQFill.Visible = False
    Me.CmdFillTIReq.Visible = False
    Else 'hide controls if source button pressed from Tracker Main form
    Me.Label34.Visible = False
    Me.txtTransmittalID.Visible = False
    End If

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

Similar Threads

  1. Replies: 6
    Last Post: 05-18-2017, 08:33 AM
  2. Replies: 6
    Last Post: 04-17-2017, 08:10 PM
  3. Replies: 5
    Last Post: 03-27-2017, 07:48 PM
  4. Replies: 5
    Last Post: 10-18-2016, 06:00 AM
  5. Command button doesn't work when DB is opened
    By buckeye4 in forum Access
    Replies: 3
    Last Post: 02-23-2011, 01:32 PM

Tags for this Thread

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