Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Dupplicate record problem

Posted on 2014-02-02
5
Medium Priority
?
363 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 52

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

Technology Partners: 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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

604 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