Check if user clicked certain button on previous fom

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rdsandy
    New Member
    • Oct 2007
    • 20

    Check if user clicked certain button on previous fom

    Hi,

    Im using Access 2003. I have a form, with two buttons and a list box. When a user selects an item in the list box, the user clicks on one of the buttons which opens up the selected record. The other button is for adding a new record. The form that opens up has a subform within a subform on the form, and at present it doesn't open up on a new record (the sub subforms). In vba code, how would you bring up a message box on form open if the open new record button was opened, so something like this:

    Code:
    Private sub Form_Open
    
    if forms!previousform!cmbNew has been pressed then[INDENT]msgbox "New record button pressed"[/INDENT]
    end if
    
    End Sub
  • FishVal
    Recognized Expert Specialist
    • Jun 2007
    • 2656

    #2
    Hi, there.

    You may use OpenArgs to pass some value to the form being opened.
    DoCmd.OpenForm method gets it as an argument.
    [code=vb]
    DoCmd.OpenForm ...., OpenArgs:="New record button pressed"
    [/code]
    Then in the opened form module it is accessible via OpenArgs property.
    Code:
    Private sub Form_Open
        MsgBox Me.OpenArgs
    End Sub
    Regards,
    Fish

    Comment

    Working...