M
mattc66 via AccessMonster.com
I have the below code that works some of the times, but not all. Here is my
issue. If there is no records in the table it works the first time. Then when
I go to add another record it says "No Current Record". If I close the form
and then re-open it, it work. I thought by adding the Set rs = Nothing it may
help. It did seem to do anything.
Private Sub TRAN_TYPE_DblClick(Cancel As Integer)
Dim rs As DAO.Recordset
Dim rs1 As DAO.Recordset
'Save any edits
If Me.Dirty Then
Me.Dirty = False
End If
'Check there is an order in the form.
If Me.NewRecord Then
MsgBox "Enter/select the order you wish to add a row to."
Else
'Append new record to the subform.
Set rs = Forms![frmOR_POInfo_C1]![frmMRPPODetail].Form.RecordsetClone
Set rs1 = Forms![frmOR_POInfo_C1]![frmWO_Cut].Form.RecordsetClone
rs1.AddNew
rs1![ASSY_ITEM] = rs![M-PO-PART-NUM]
rs1![Type] = rs![M-PO-TRAN-TYPE]
rs1![JOB_CMP_DATE] = rs![M-PO-DATE-DUE]
rs1![QTY] = rs![SumOfM-PO-QTY]
rs1.Update
Set rs = Nothing
End If
Set rs = Nothing
Set rs1 = Nothing
End Sub
issue. If there is no records in the table it works the first time. Then when
I go to add another record it says "No Current Record". If I close the form
and then re-open it, it work. I thought by adding the Set rs = Nothing it may
help. It did seem to do anything.
Private Sub TRAN_TYPE_DblClick(Cancel As Integer)
Dim rs As DAO.Recordset
Dim rs1 As DAO.Recordset
'Save any edits
If Me.Dirty Then
Me.Dirty = False
End If
'Check there is an order in the form.
If Me.NewRecord Then
MsgBox "Enter/select the order you wish to add a row to."
Else
'Append new record to the subform.
Set rs = Forms![frmOR_POInfo_C1]![frmMRPPODetail].Form.RecordsetClone
Set rs1 = Forms![frmOR_POInfo_C1]![frmWO_Cut].Form.RecordsetClone
rs1.AddNew
rs1![ASSY_ITEM] = rs![M-PO-PART-NUM]
rs1![Type] = rs![M-PO-TRAN-TYPE]
rs1![JOB_CMP_DATE] = rs![M-PO-DATE-DUE]
rs1![QTY] = rs![SumOfM-PO-QTY]
rs1.Update
Set rs = Nothing
End If
Set rs = Nothing
Set rs1 = Nothing
End Sub