Results 1 to 10 of 10
  1. #1
    Join Date
    Aug 2010
    Location
    Brandıs nad Labem - Czech Republic
    Posts
    36

    Question Move bookmark to "new" record

    Hi,

    I found it is not difficult to create a new record from code and move to it. I did it this way:

    Code:
        'open the new form
        DoCmd.OpenForm "MyForm"
        
        'take it to the selected record
        Set rs = Forms!MyForm.Recordset
        rs.AddNew
        rs.Update
        rs.Bookmark = rs.LastModified
         
        Set rs = Nothing
    It has a drawback. It really creates a new row and saves it.
    But when using navigation buttons you can create a new record (or navigate beyond the last one) and it will be saved only iff the user enters some values.



    I'd like to have the same.
    A "create new" button opens this form where I want the bookmark (the selected record) to be the new record, but save it only if values are entered. I tired moving beyond the last record (.MoveLast and then .MoveNext) but that throws an error...

    Any ideas? Thanks a lot!

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You can set the DataEntry property to YES if you only want to see "New" records. The OpenForm command supports a DataMode of ADD as well.

  3. #3
    Join Date
    Aug 2010
    Location
    Brandıs nad Labem - Czech Republic
    Posts
    36
    It is maybe hard to explain or hard to understand what I'm after. I'm not after limiting the user to new records.

    When you use the form's built-in navigation bar to get to a new record (navigate after the last or press "new") you get a blank record which gets saved iff you modify it.

    When I create a new record from code, set the bookmark to it and show the form, the record is already saved and will stay there even if the user changes his mind (does not fill in data). Blank records will emerge and more will come.

    The best I can imagine would be to tell the form to do the same as if I use the built-in navigation bar (offer blank form, save if filled out).

    Other not so pretty ideas are to remove blank records, when leaving them in this form.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Why not just use DoCmd.GoToRecord New? There is no need to set the Bookmark.

  5. #5
    Join Date
    Aug 2010
    Location
    Brandıs nad Labem - Czech Republic
    Posts
    36
    THANK YOU! You saved my day :-)

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You're welcome. Are you ready to follow the link in my sig and mark this thread as Solved?

  7. #7
    Join Date
    Aug 2010
    Location
    Brandıs nad Labem - Czech Republic
    Posts
    36
    I do use the "solved" feature here. It makes the forum better readable for those who seek for answers. I was just waiting for a successful test. And it works! :-)

    For dummies: "DoCmd.GoToRecord New" == "DoCmd.GoToRecord , , acNewRec"

    BTW among my threads there is 1/5 not marked as solved at the moment:
    https://www.accessforums.net/access/...enes-7234.html
    ...where I'm asking how to address the properties of subforms
    Last edited by BayerMeister; 08-17-2010 at 12:03 AM. Reason: removing irrelevant, adding details

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Thank you BayerMeister and I'm looking at your other thread now. Great pictures BTW. What do you use to do the screen capture?

  9. #9
    Join Date
    Aug 2010
    Location
    Brandıs nad Labem - Czech Republic
    Posts
    36
    I use the "Print Screen" button on my keyboard (the one on all keyboards sin 1970's), the content of the screen gets copied to the clipboard. Then I can use any painting program and just paste it in with Ctrl+V.
    I use and like Paint.NET for it's moderate amount of features and ease of use.

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I knew about PrintScreen and using a Paint program. It was just so well done that I thought you were not doing the editing in a Paint program. Seems like a lot of work but the effect is great! Thanks.

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

Similar Threads

  1. What does "not a valid bookmark" mean?
    By ejohnso4 in forum Forms
    Replies: 3
    Last Post: 06-05-2014, 08:49 AM
  2. Replies: 1
    Last Post: 07-04-2010, 03:31 PM
  3. Replies: 3
    Last Post: 02-23-2010, 06:32 PM
  4. Creating "Edit Record" link in table column
    By joshearl in forum Forms
    Replies: 1
    Last Post: 12-25-2009, 11:17 AM
  5. Replies: 0
    Last Post: 11-03-2009, 11:42 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