Results 1 to 7 of 7
  1. #1
    aliensporez is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Posts
    3

    Using Form Button to Duplicate record, however want some fields cleared after

    Hello all, some assistance would be appreciated.

    I currently have a simple database that allows the user to duplicate the current record. What I would like to happen is that once the person clicks on "Copy This Record" the record is copied, but I'd like two fields "Date" and "Hours" fields to be cleared. What would be the best way to code this?



    Thanks!

    Click image for larger version. 

Name:	Access Copy question.jpg 
Views:	12 
Size:	85.9 KB 
ID:	6390

  2. #2
    mejia.j88 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Nov 2011
    Location
    california
    Posts
    228
    private sub NAMEofbutton_click()
    me.nameoffield=""
    me.nameofotherfield=""
    end sub

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    I don't allow empty strings in tables. Also, date and number datatypes fields cannot have empty string. Set to Null instead.
    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.

  4. #4
    aliensporez is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Posts
    3
    Hmm, nothing happened... Here's my code:

    Private Sub Duplicate_Click()
    Me.Text33 = Null
    Me.Text37 = Null
    End Sub


    I also tried mejia.j88's suggestion of "" with no luck.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Where is the code that copies the record and sets focus on new record?
    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.

  6. #6
    aliensporez is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Posts
    3
    I am simply using the Access off-the-shelf 'duplicate record' functionality. I'm not sure how the OTS functionality sets focus after the copy to be honest. For example, below I just created a simple command button, and chose "record operations -> duplicate record.' That's the method currently in use, I have not added any code to expand on that base functionality.

    Click image for larger version. 

Name:	duplicate.JPG 
Views:	8 
Size:	51.5 KB 
ID:	6393

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Sorry, I should have been specific. We need to see the code that copies the record and sets focus on new record so can analyse. If you let the wizard do the work it probably created an embedded macro. I don't use macros, only VBA.

    Is the Click event property of the button set to [Embedded macro]? If yes that means the VBA code with our suggestion is not getting executed. As far as I know macro cannot set field values, I have tried.
    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.

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

Similar Threads

  1. Button to duplicate part of record
    By jbickl in forum Forms
    Replies: 3
    Last Post: 02-08-2012, 10:44 PM
  2. Replies: 1
    Last Post: 09-08-2011, 08:50 AM
  3. Replies: 10
    Last Post: 04-19-2011, 03:38 PM
  4. Replies: 10
    Last Post: 03-21-2011, 02:46 PM
  5. Duplicate last record to next record in form
    By jdhaldane in forum Forms
    Replies: 4
    Last Post: 12-17-2010, 04:22 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