?
Solved

Dupplicate record problem

Posted on 2014-02-02
5
Medium Priority
?
361 Views
Last Modified: 2014-02-07
I am trying to duplicate a main form's record and records from the subform or child table.

When I run the following code the form should move to the new record and supply the DuplicateOrderDetails Apend query with the new Account code. But The form stays on the current record and just copies the data to the same data set?

Dim dbs As DAO.Database, rst As DAO.Recordset
Me.txtAccountCode = Me.AccountCode
Me.txtItemNumber = Me.Details.Form.ItemNumber

' Return Database variable pointing to current database.
Set dbs = CurrentDb
Set rst = Me.RecordsetClone

'On Error GoTo Err_btnDuplicate_Click

' Tag property to be used later by the append query.
Me.Tag = Me![AccountCode]

' Add new record to end of Recordset object.
With rst
   .AddNew
     
      !CustomerName = Me!CustomerName
      !ProjectRef = Me!ProjectRef & " B"
      !Phone = Me!Phone
      !Fax = Me!Fax
      !Email = Me!Email
      !Ref = Me!Ref
      !OrderNumber = Me!OrderNumber
      !CustomerOrderNumber = Me!CustomerOrderNumber
      '!DateCreatedProject = Me!TodaysDate
     
   .UpDate                     ' Save changes.
   .Move 0, .LastModified
   
End With

MsgBox "new account code is  " & [txtAccountCode]
Me.Bookmark = rst.Bookmark
DoCmd.SetWarnings True
DoCmd.OpenQuery ("DuplicateOrderDetails")

I am pretty sure that the Tag property is redundent code.

Also on occation I get chinese writing in my tables. See attached
Capture4.PNG
0
Comment
Question by:DatabaseDek
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 27

Assisted Solution

by:MacroShadow
MacroShadow earned 800 total points
ID: 39828418
Try .Move 1, .LastModified
The Chinese seems to be a mask.
0
 
LVL 51

Accepted Solution

by:
Gustav Brock earned 1200 total points
ID: 39828937
This works for me:

   .UpDate                     ' Save changes.
   .MoveLast
   Me.Bookmark = .Bookmark

/gustav
0
 

Author Comment

by:DatabaseDek
ID: 39829126
I think the chinese is me trying (unthinkingly) to add text to a number field.

What's the difference between .Move 0 and .Move 1?

Derek
0
 
LVL 27

Expert Comment

by:MacroShadow
ID: 39829175
move 1 will move down 1 row, which would seem what you want to do.

p.s. I'm not sure why you use a append query to add the data instead of a record set.
0
 

Author Comment

by:DatabaseDek
ID: 39841869
Is a record set different from a query?
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question