Solved

Duplicate forms Recordset

Posted on 2013-11-18
3
370 Views
Last Modified: 2013-11-18
Hello, with my code below I'm attempting to populate a forms recordset via an SQL statement then clone the record.

I'm getting the following error:

Within the recordsetclone I'm getting this error on the .AddNew:

"No such interface supported"

Private Sub S_Click()

If MIRROR.Value > "" Then

Dim NewMDRNumber As Integer

'get the selected mdr
Dim myDMR As Integer
myDMR = MIRROR.Value

'fill NewMDRNumber number with next mdr number
NewMDRNumber = DLookup("myDMR", "GetNextDMRID")

'populate forms recored set with select statement
Set RST = New ADODB.Recordset
RST.Open "Select * from [DMR Tracking] Where [DMR#] = " & myDMR & "", _
CurrentProject.Connection, adOpenKeyset, adLockOptimistic
Set Forms("Type of DMR").Recordset = RST

'Duplicate the record
With Me.RecordsetClone
.AddNew
![DMR#] = NewMDRNumber
![DATE Issued] = Me.[DATE Issued]
![TYPE OF DMR] = Me.[TYPE OF DMR]
![PART NUMBER] = [PART NUMBER]
![PART NAME] = [PART NAME]
![Program] = [Program]
![Customer] = [Customer]
![SUPPLIER] = [SUPPLIER]
![Area] = [Area]
![LOT NUMBER] = [LOT NUMBER]
![QTY SUSPECT] = [QTY SUSPECT]
![PPM QUANTITY] = [PPM QUANTITY]
![WHERE LOCATED] = [WHERE LOCATED]
![WHO PREPARED] = [WHO PREPARED]
![QA Eng] = [QA Eng]
![JobNumber] = [JobNumber]
![PINNumber] = [PINNumber]

.Update

'Save the primary key value, to use as the foreign key for the related records.
.Bookmark = .LastModified

'Display the new duplicate.
Me.Bookmark = .LastModified
End With

Exit_Handler:
Exit Sub

Err_Handler:
MsgBox "Error " & Err.Number & " - " & Err.Description, , "cmdDupe_Click"
Resume Exit_Handler

Else

MsgBox "Select the MDR to duplicate."

End If

 
End Sub

Open in new window

0
Comment
Question by:gogetsome
  • 2
3 Comments
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 500 total points
ID: 39657196
I believe you need to use DAO.Recordset for the RecordsetClone:

Dim rsClone As DAO.Recordset
Set rsClone = Me.RecordsetClone
rsClone.AddNew

etc.

and probably for the source also.

/gustav
0
 

Author Closing Comment

by:gogetsome
ID: 39657289
Thank you for pointing me in the right direction.
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 39657679
You are welcome!

/gustav
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

840 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