Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Duplicate forms Recordset

Posted on 2013-11-18
3
Medium Priority
?
394 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 52

Accepted Solution

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

Expert Comment

by:Gustav Brock
ID: 39657679
You are welcome!

/gustav
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

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 …
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
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…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

824 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