473,396 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Add a new record and copy one field from the previous record

I want to add a new record and then copy the field DCDate over to the new record, but when I click on the command button it only adds a new record, but didn't copy the DCDate over. Can any body help?
here is my code.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdAddNew_Click()
  2.  
  3. DoCmd.GoToRecord , , acNewRec
  4. [Forms]![frmMedRec]![txtDCDate] = Me.txtDCDate
  5. [Forms]![frmMedRec]![cboMRN].SetFocus
  6.  
  7. End sub
Thanks
Apr 5 '07 #1
3 2027
Rabbit
12,516 Expert Mod 8TB
I want to add a new record and then copy the field DCDate over to the new record, but when I click on the command button it only adds a new record, but didn't copy the DCDate over. Can any body help?
here is my code.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdAddNew_Click()
  2.  
  3. DoCmd.GoToRecord , , acNewRec
  4. [Forms]![frmMedRec]![txtDCDate] = Me.txtDCDate
  5. [Forms]![frmMedRec]![cboMRN].SetFocus
  6.  
  7. End sub
Thanks
If I understand correctly, this is all on one form.
You have to store the old date in a temporary variable before moving to a new record and then assigning it. Right now what you're doing is assigning the control to itself.
Expand|Select|Wrap|Line Numbers
  1. [Forms]![frmMedRec]![txtDCDate] = Me.txtDCDate
They're both the same thing.
What you're looking for is:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdAddNew_Click()
  2.  
  3. Dim TempStr As String
  4. TempStr = Me.txtDCDate
  5. DoCmd.GoToRecord , , acNewRec
  6. Me.txtDCDate = TempStr
  7. [Forms]![frmMedRec]![cboMRN].SetFocus
  8.  
  9. End sub
Apr 5 '07 #2
Thanks Rabit! It worked!

Elaine
Apr 5 '07 #3
Rabbit
12,516 Expert Mod 8TB
Not a problem, good luck.
Apr 5 '07 #4

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

Similar topics

4
by: Marleen | last post by:
I have a database that manages my webstore. Each store item record has 26 fields. I would like to have a way when adding new items to be able to just copy the previous item when most everything is...
8
by: Mark | last post by:
When my form goes to a new record, I have a procedure that copies the last record added to the form's underlying table into the form. The intent is that a series of new records may have the same...
15
by: Steve | last post by:
I have a form with about 25 fields. In the BeforeUpdate event of the form, I have code that sets the default value of each field to its current value. For a new record, I can put the focus in any...
2
by: MLH | last post by:
Fields in MyTable: PostID PostDate RollQtyXfer RollDenomination RollCount37 RollCount23
3
by: Chris | last post by:
Is it possiable to have a iif function in a query where it looks at the next record. for example if I run the query which lists years and if the results in record 2 equals the result in record 1...
8
by: Jeff | last post by:
A client wants a press of the Enter key in a field on a continuous form to grab the value of that field from the previous record. But if they have typed a value and then hit Enter it shouldn't. ...
1
by: roveagh1 | last post by:
Hi I've been using the 2 year old link below to repeat values from previous record field into current corresponding field. It's worked fine for text but the last piece of advice was to use the same...
3
prn
by: prn | last post by:
Hi folks, I've got something that's driving me crazy here. If you don't want to read a long explanation, this is not the post for you. My problematic Access app is a DB for keeping track of...
7
by: Neil | last post by:
Was working in A2003 and noticed that the Save Record item on the Records menu was not available when the record was not dirty. In A2000, Save Record was always available. (This is a problem for me...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.