Solved

Dupplicate record problem

Posted on 2014-02-02
5
348 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 26

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 26

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now