Results 1 to 4 of 4
  1. #1
    Pawtang's Avatar
    Pawtang is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Mar 2021
    Posts
    91

    Setting form to open New Record from command button and not form's OnLoad

    My main data entry form can be opened from various other locations representing different contexts: for example, I have a list that shows all "open" records in a continuous form with a button on each line to open the detail view (main form) for that record. Because I have that command button open the form to the specific record, I can't have an OnLoad property for the form that sets it to New Record, or it would kill that function and always open to new. What I'd like to do is have my primary entry point to this form - a button in the main menu - load the form to a New Record.



    I have started with a VBA sub rather than Macros because I think that will be an easier method to accomplish this, but I'm not sure what property to set to achieve this.

    Code:
    Private Sub openFrmRMA_Click()    
    DoCmd.OpenForm "frmRMA"
    End Sub

  2. #2
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,407
    Use the OpenArgs argument in the docmd.openform statement. The openargs value can be evaluated by the form's on_open event to know what it's expected to do.

  3. #3
    Pawtang's Avatar
    Pawtang is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Mar 2021
    Posts
    91
    Quote Originally Posted by davegri View Post
    Use the OpenArgs argument in the docmd.openform statement. The openargs value can be evaluated by the form's on_open event to know what it's expected to do.
    Worked like a charm and glad to know about that property too! Seems universally useful

  4. #4
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,407
    Worked like a charm and glad to know about that property too! Seems universally useful
    Glad it was a solution for you. Good luck with the project!

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

Similar Threads

  1. Replies: 4
    Last Post: 08-10-2018, 12:00 AM
  2. Replies: 3
    Last Post: 07-22-2018, 02:05 PM
  3. Replies: 13
    Last Post: 06-20-2018, 03:18 AM
  4. Replies: 5
    Last Post: 10-18-2016, 06:00 AM
  5. Replies: 2
    Last Post: 05-11-2012, 11:52 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