Solved

Dupplicate record problem

Posted on 2014-02-02
5
360 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 200 total points
ID: 39828418
Try .Move 1, .LastModified
The Chinese seems to be a mask.
0
 
LVL 50

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
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 …
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

688 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