Solved

Duplicate forms Recordset

Posted on 2013-11-18
3
372 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 50

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 50

Expert Comment

by:Gustav Brock
ID: 39657679
You are welcome!

/gustav
0

Featured Post

Independent Software Vendors: 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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

696 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