Solved

Duplicate forms Recordset

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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…

759 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

22 Experts available now in Live!

Get 1:1 Help Now