Results 1 to 10 of 10
  1. #1
    djclinton15 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Nov 2015
    Posts
    123

    How to open a Form to a New Record?

    Pardon me, I've used Access for 1-year & lost all of my little notes. Can someone please give me the code for a Form to open to a New Record upon opening a Form?


    I will greatly appreciate it & thanks in advanced!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    One way:

    DoCmd.OpenForm "form name", , , , acFormAdd
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    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
    Or, if you're opening the Form directly, rather than from another Form:
    Code:
    Private Sub Form_Load()
     DoCmd.GoToRecord , , acNewRec
    End Sub

    Linq ;0)>

  4. #4
    djclinton15 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Nov 2015
    Posts
    123
    Thanks Ling, that's the code I was looking for except I cannot open my VBA. It says, "Unexpected error, quitting." Could the whole db be corrupted?

  5. #5
    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
    Sorry, but what, exactly, does "I cannot open my VBA" mean?

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Exactly what are you doing when you get that message?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    djclinton15 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Nov 2015
    Posts
    123
    Ling: I get a message saying, "Unexpected error, quitting" as I stated above.

    June: I get 2-choices, either "OK" which gets me no where or "Help" & directs me to this website, https://msdn.microsoft.com/en-us/lib...ffice.15).aspx that doesn't tell me anything.

  8. #8
    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
    No, you haven't! You said "I cannot open my VBA" which doesn't really isn't clear. Do you get the message when you try to go into the VBA code behind your Form? Do you get it when you try to simply open your Form? 'Open my VBA' doesn't really make since.

  9. #9
    djclinton15 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Nov 2015
    Posts
    123
    Ling, please except my apology, I meant went i click on, "View Code" under the Design ab in Form Design View. I thought clicking on, "View Code" opens up the VBA Window? Maybe I'm mistaking the two?

  10. #10
    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
    Yes, it should open up the VBA module for the Form! That would suggest that corruption has reared its ugly head! First line of defense is to

    • Create a new, blank database file
    • Import everything from the errant database into the new database file
    • Try running the new database

    Linq ;0)>

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

Similar Threads

  1. Replies: 10
    Last Post: 12-17-2014, 03:31 PM
  2. Replies: 4
    Last Post: 12-16-2014, 05:08 PM
  3. Replies: 2
    Last Post: 03-13-2013, 06:13 PM
  4. Replies: 3
    Last Post: 08-26-2012, 10:04 PM
  5. Replies: 1
    Last Post: 05-03-2012, 02:25 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