Results 1 to 9 of 9
  1. #1
    accessmatt is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    199

    Way to default form always to new record


    What's the simplest way to make sure my form always opens up to a new (i.e. blank) record? Currently it opens to the first record in the database.

    Thanks,

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    If you set the Form's Data Entry Property to Yes, it will open to a New Record, but only allow the addition of New Records; existing Records cannot be viewed/edited.

    To view existing Records but always open to a New Record:

    Code:
    Private Sub Form_Load()
      DoCmd.GoToRecord , , acNewRec
    End Sub

    Linq ;0)>

  3. #3
    accessmatt is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    199
    Thanks Missinglinq, that worked perfectly!

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Glad we could help!

    Linq ;0)>

  5. #5
    accessmatt is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    199
    Missinglinq,

    all of a sudden I started getting an error of Return without GoSub. Any ideas why ?

    thanks,

  6. #6
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    You need to start a new thread for this, with an appropriate title, but one common cause is copying and pasting code into the code window, and accidentally pasting one procedure within another, something like

    Code:
    Private Sub TextboxOne_AfterUpdate()
      'code here for TextboxOne
    
      Private Sub YourCombobox_AfterUpdate()
          'code here for YourCombobox
      End Sub
    
    End Sub
    so I'd start by looking at the code behind the errant Form. When it errors out are you offered the option to debug, and if so, and you click to debug, where does it take you?

    Linq ;0)>

  7. #7
    accessmatt is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    199
    and it also seems to be breaking when I save as ACCDE. any thoughts on that one?

  8. #8
    accessmatt is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    199
    Linq, Any idea why it would just not work when i save as ACCDE?

  9. #9
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Also,check out the Docmd.Openform command.

    From code (a button click event) you would use :
    Code:
    DoCmd.OpenForm "frmYourFormName", , , , acFormAdd
    The Form's Data Entry Property should be No. The form would always open in add mode (a new record).

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

Similar Threads

  1. Replies: 15
    Last Post: 07-24-2014, 09:45 AM
  2. Replies: 4
    Last Post: 12-19-2013, 05:35 PM
  3. Replies: 7
    Last Post: 07-20-2013, 03:59 AM
  4. Replies: 3
    Last Post: 11-15-2012, 06:59 PM
  5. Replies: 3
    Last Post: 06-27-2009, 03:53 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