By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
462,320 Members | 624 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 462,320 IT Pros & Developers. It's quick & easy.

How to copy data from a field on a form to same field in new form?

P: 8
What I am trying to do is to , while in the current form, copy data from a field in the current record and paste it into the same field on the same form of a new record. This code below works in one database but it does not work in my current Db. I get the following error running the code below.

Run time error '438':
"Object doesn't support this property or method"

Expand|Select|Wrap|Line Numbers
  1. Private Sub Template_Click()
  2.  
  3. Const cQuote = """"
  4.  
  5. Me!Project_Record_ID.DefaultValue = cQuote & Me!Project_Record_ID & cQuote
  6.  
  7. DoCmd.GoToRecord , , acNewRec
  8.  
  9. DoCmd.RunCommand acCmdSaveRecord       
  10.  
  11. End Sub
  12.  
Nov 7 '10 #1
Share this Question
Share on Google+
3 Replies

ADezii
Expert 5K+
P: 8,740
Expand|Select|Wrap|Line Numbers
  1. Const cQuote = """"
  2. Dim ctl As Control
  3.  
  4. Set ctl = Me![Project_Record_ID]
  5.  
  6. ctl.DefaultValue = cQuote & Me![Project_Record_ID] & cQuote
  7.  
  8. DoCmd.RunCommand acCmdSaveRecord
  9.  
  10. DoCmd.GoToRecord , , acNewRec
Nov 8 '10 #2

P: 8
Thanks again ADezii!

I changed to your suggested code and I now get the following error:
error 13 - Type mismatch

...on line 'Set ctl = Me![Project_Record_ID]'

Any idea why?
Nov 8 '10 #3

ADezii
Expert 5K+
P: 8,740
No idea, since the Code is perfectly valid. Try Plan B:
Expand|Select|Wrap|Line Numbers
  1. Const cQuote = """"
  2.  
  3. Me![Project_Record_ID].DefaultValue = cQuote & Me![Project_Record_ID] & cQuote
  4.  
  5. DoCmd.RunCommand acCmdSaveRecord
  6.  
  7. DoCmd.GoToRecord , , acNewRec
Nov 8 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.