The revolutionary project management tool is here! Plan visually with a single glance and make sure your projects get done.
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
Join the community of 500,000 technology professionals and ask your questions.