Solved

Dupplicate record problem

Posted on 2014-02-02
5
358 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
  • 2
  • 2
5 Comments
 
LVL 27

Assisted Solution

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

Accepted Solution

by:
Gustav Brock earned 300 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

830 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