Results 1 to 8 of 8
  1. #1
    Jrw76 is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Dec 2013
    Posts
    38

    duplicating a record but changing a field value.

    I have a form that allows users to enter data.
    There will be times where these records will be duplicated except for one field. That field is called 'Hull'. I have a checkboxes included for each option of Hull. We'll call them 'Hull1', 'Hull2', 'Hull3', 'Hull4', 'Hull5', 'Hull6'. The Idea is when the user is entering the information, he may enter Hull1 in the 'Hull' field, but it may also be used for 'Hull2', 'Hull4', 'Hull6' - so when he clicks on the checkboxes for 'Hull2', 'Hull4', 'Hull6', the record will duplicate, change the value 'Hull', and append to the table. This is the code I came up with, but it's not working correctly.

    Private Sub Check120_AfterUpdate()


    If Check120 = "-1" Then
    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
    Me.Hull = "Hull2"
    DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70
    End If
    End Sub

  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,770
    Are you doing this on a bound form? I have never used DoMenuItem. What are items 8, 2, 5?

    Why doesn't it work - error message, wrong results, nothing?
    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
    Jrw76 is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Dec 2013
    Posts
    38
    Not sure what the numbers represent...It duplicates the records, just ALL records and gave me an error table to append the errors later. I stole the code from the button wizard, and changed it to do what I needed...didn't work. Any suggestions?

    Oh, and yes, this form is bound to a table that captures the data.

  4. #4
    Jrw76 is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Dec 2013
    Posts
    38
    I think I have to reset the checkbox back to 0

  5. #5
    Jrw76 is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Dec 2013
    Posts
    38
    Nope, different mistakes...What are your suggestions?

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    It would help you and the reader if you would write down, in plain English, WHAT you are trying to do.

    DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70
    this sort of thing has been around at least since Access97. It is the genreated code when you use a wizard --at least it used to be.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I've never used DoMenuItem. I think the method is discouraged. Think I would use code that sets the DefaultValue property of each control.

    http://access.mvps.org/access/forms/frm0012.htm

    or something like

    http://support.microsoft.com/kb/210236
    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.

  8. #8
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I believe DoCmd.DoMenuItem is being replaced with Docmd.RunCommand

    acCommand Enumeration
    http://msdn.microsoft.com/en-us/libr.../ff821354.aspx

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

Similar Threads

  1. Replies: 19
    Last Post: 05-13-2013, 01:26 AM
  2. Replies: 1
    Last Post: 02-20-2013, 01:30 PM
  3. Replies: 4
    Last Post: 02-13-2013, 10:46 AM
  4. Changing Misspelled Record
    By tylerg11 in forum Access
    Replies: 5
    Last Post: 09-27-2011, 10:15 AM
  5. duplicating and editing the record
    By Airis in forum Forms
    Replies: 1
    Last Post: 04-12-2010, 07:41 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