Hi,
I have read that it is important to close any objects and de-reference them in order to prevent corruption.
Here is some code that may have caused problems in my database (I've only just added the last line). Could someone check it to see if I've closed and defererenced everything I should. For instance do I need to set me.recordsetclone = nothing and what about me.bookmark?
I have read that it is important to close any objects and de-reference them in order to prevent corruption.
Here is some code that may have caused problems in my database (I've only just added the last line). Could someone check it to see if I've closed and defererenced everything I should. For instance do I need to set me.recordsetclone = nothing and what about me.bookmark?
Code:
Me.RecordsetClone.FindFirst "[DrawingNum]= '" & Forms!frmDrawingsRegister![txtDrawingNum] & "' And [Rev] = " & Forms!frmDrawingsRegister![txtRevision] & ""
If Not Me.RecordsetClone.NoMatch Then 'if drawing num AND rev number exists
Me.Undo
Me.Bookmark = Me.RecordsetClone.Bookmark 'make record found the current record
Call disableControls(True, True) 'Disable textfields
Else
Me.RecordsetClone.FindFirst "[DrawingNum]= '" & Forms!frmDrawingsRegister![txtDrawingNum] & "'"
If Not Me.RecordsetClone.NoMatch Then 'if drawing number entered exists
Me.Undo 'undo add new record
Me.Bookmark = Me.RecordsetClone.Bookmark 'go to the record in masterform with this drawing num
Me.frmDrawingRevisions.SetFocus 'add new record to Revisions subform
DoCmd.GoToRecord , , acNewRec
msgboxAns = MsgBox("Do you wish to add a new revision of this drawing?", vbYesNo, "Add new revision of drawing?")
Forms!frmDrawingsRegister!frmDrawingRevisions!txtLatestIssueDate.SetFocus
Else 'drawing does not exist
msgboxAns = MsgBox("Do you wish to add a new drawing?", vbYesNo, "Add new drawing?")
End If
If msgboxAns = vbYes Then
Me.txtOrderNum.SetFocus
Forms!frmDrawingsRegister!frmDrawingRevisions!txtRev.Value = Me.txtRevision.Value
Forms!frmDrawingsRegister!frmDrawingRevisions!txtDrawingStatus.Value = "Latest Revision"
Call disableControls(False, False) 'enable textfields
Call updateRevisionStatus(Me.txtDrawingNum.Value)
Else
Me.Undo 'undo new drawing record record
DoCmd.GoToRecord , , acPrevious
Me.txtRevision.Value = ""
Call disableControls(True, True) 'Disable textfields
End If
End If
Me.txtRevision.Value = ""
End If
Me.RecordsetClone.Close