Results 1 to 3 of 3

Access VBA, copy current value to new record

This is a discussion on Access VBA, copy current value to new record within the Microsoft Access forums, part of the Question Forums category; Hi, I am trying to copy some selected values from the current record to a new record, if it is ...

  1. #1
    Board Regular stu999's Avatar
    Join Date
    Aug 2008
    Location
    Oxfordshire, UK
    Posts
    183

    Default Access VBA, copy current value to new record

    Hi, I am trying to copy some selected values from the current record to a new record, if it is a numeric field it copies fine, but if it is a text field it gives me an error. I don't want to set up default values in the original table as I am creating a document revision system where they click a button to create the new revision based on the previous one.
    Code is
    Code:
     
    Me.Dieblock.DefaultValue = Me.Dieblock.Value
    Trying to copy a text field value gives me this in the new record; #Name?

    Thanks
    Stu

    You learn something new everyday!

  2. #2
    Board Regular
    Join Date
    Apr 2007
    Location
    Pennsylvania
    Posts
    166

    Default Re: Access VBA, copy current value to new record

    Stu
    What about something like OnEnter SendKeys "^""" '( ctrl + single quote ) - sometimes called 'ditto' ?

  3. #3
    Board Regular stu999's Avatar
    Join Date
    Aug 2008
    Location
    Oxfordshire, UK
    Posts
    183

    Default Re: Access VBA, copy current value to new record

    Hi, Thanks for the suggestion, I will have a look at that option, but i got it working by declaring a variable then passing it to the record after the new record was opened.
    Code:
     
    strDie = [Dieblock]
    DoCmd.GoToRecord , , acNewRec
    Me.Dieblock.Value = strDie
    Stu

    You learn something new everyday!

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


DMCA.com