I am having issues with memory still being allocated when opening a form from an mdi when the form is closed.
I have attempted to change the mdi code when the form is called, using set formname = nothing.
This does not appear to be clearing up form, and it's memory. When the form is unloaded the session is cleared. After all objects are cleared they also set to nothing.
Private Sub mnuCreateTicket_Click()
Screen.MousePointer = vbHourglass
Load frmSearchForPNR
Screen.MousePointer = vbNormal
frmSearchForPNR.Show
Set frmSearchForPNR = Nothing
End Sub
'/////////////////////////////////////////////////////////////////////////////////////////////
'// NAME : frmSearchForPNR
'// PURPOSE : frmSearchForPNR is displayed to give the user the ability to select a PNR
'// that is ready to be ticketed
'//
'/////////////////////////////////////////////////////////////////////////////////////////////
Option Explicit
Private Const C_CLR As String = ""
Private Const C_DATE_FORMAT As String = "dd/mm/yyyy HH:MM AM/PM"
Private Const C_PNR_ID As String = "PNR ID="
Private Const C_PARM_PNR_ID As String = "PNRID"
Private Const C_PARM_PNR_TICKETER_ID As String = "TicketerID"
Private Const C_PARM_PNR_NOTES As String = "Notes"
Private Const C_TICKETERS As String = "Ticketers"
Private Const C_TKT_ID As String = "TKTer ID= "
Private Const C_CURRENT_PNR As String = "Current PNR: "
Private Const C_LAST_MODIFIED_KEY As String = "Last Modified="
Private Const C_PNR_VERSION_SEPARATOR As String = "/"
Private Const C_IMAGE_OPEN As String = "open"
Private Const C_IMAGE_CLOSE As String = "close"
'// Constants Error Messages
Private Const C_ERR_MSG_CONTACT_SYSAMINISTRATOR As String = "Please contact System Administration"
Dim ndeFOUNDPNR As Node
Dim ndeCancelPNR As Node
Dim ndePNR As Node
Dim ndeSelectedPNR As Node
Dim blnNewPNR As Boolean
Private m_objsession As oasisdbcnn.cSession
Private Sub Form_Load()
'////////////////////////////////////////////////////////////////////////////////////////////////////////
'// Sub : Form_Load
'// Purpose : Loads the form and populates the controls with data that is issued in this sub.
'//
'////////////////////////////////////////////////////////////////////////////////////////////////////////
On Error GoTo errhandler
Const C_PNRID As String = "PNRID = "
Set m_objsession = New oasisdbcnn.cSession
Call m_objsession.Init(gobjSc, osmReadWrite)
'// clear text boxes ready for input from user
txtPNRDetails.text = C_CLR
txtSearchForPartialPNR.text = C_CLR
'// call to setup the listview column headers
Call createHeaders
'// call to load the listview control with new pnrs
Call DisplayAllPNRS
'// load treeview control with partially complete pnrs
Call DisplayPartialPNRS
'// check for if no items are populated on the listview control, if so we can at least create a ticket
If Me.lstviwPNR.ListItems.Count > 0 Then
Set gobjPNR = gobjPNRS.Search(Mid(Me.lstviwPNR.SelectedItem.Key, Len(C_PNRID) + 1))
txtPNRDetails.text = CrsText(gobjPNR.PNRText)
Me.cmdCreateTicket.Enabled = True
Else
'// can't create a ticket as no new pnrs are retrieved from the database
Me.cmdCreateTicket.Enabled = False
End If
Me.tvwPNR.Nodes.Item(1).Expanded = True
Exit Sub
errhandler:
If Err.Number > vbObjectError Then
Call DisplayError(Err.Number - vbObjectError, Err.Description, Err.source)
Else
Call DisplayError(Err.Number, Err.Description, "frmSearchForPNR")
End If
End Sub
Private Sub cmdCancel_Click()
'/////////////////////////////////////////////////////////////////////////////////////
'// SUB : cmdCancel_Click
'// PURPOSE : Unloads the form
'////////////////////////////////////////////////////////////////////////////////////
Unload Me
End Sub
Private Sub Form_Unload(Cancel As Integer)
If (Not m_objsession Is Nothing) Then
m_objsession.DeInit
Set m_objsession = Nothing
End If
From the code you posted... I do not see a few things.
1 - Is frmSearchForPNR unloaded or just flashes on the screen.
2 - I see no database connection/recordset open, close or set to nothing (is this happening somewhere else).
The form gets loaded. The connections are loaded and cleaned up in other classes.
Here is some of the search code. (This form is huge so I can't put all the code up)
Private Sub cmdSearch_Click()
'/////////////////////////////////////////////////////////////////////////////////////
'// SUB : cmdSearch_Click
'// PURPOSE : Launches code to search on the PNR number that the user has entered
'// and retrieve PNR and to call function LoadDataIntoListViwPNRControl(recPNR)
'// INPUTS : NONE
'// OUTPUTS : NONE
'////////////////////////////////////////////////////////////////////////////////////
On Error GoTo PROC_ERR
Const PROCEDURE_NAME = "cmdSearch_Click"
Const C_NO_PNRS_FOUND As String = "There are no PNR's that meet your match!"
Const C_NO_PNR As String = ""
Screen.MousePointer = vbNormal
If txtRelocNumber.text = C_NO_PNR Then
MsgBox "Please enter a PNR/Reloc Number", vbOKOnly + vbInformation, "Missing PNR/Reloc Number"
Exit Sub
End If
Screen.MousePointer = vbHourglass
If lstviwPNR.ListItems.Count > 0 Then
lstviwPNR.ListItems.Clear
End If
Dim cmdSearchForPnr As OasisDBCnn.cStoredProcedure
Set cmdSearchForPnr = m_objSession.StoredProcedures("OASISqrySearchForPNR")
Dim recPNR As ADODB.Recordset
With cmdSearchForPnr
.Parameters("RelocNo") = Me.txtRelocNumber.text
Set recPNR = .Execute
End With
If lstviwPNR.ListItems.Count > 0 Then
lstviwPNR.ListItems.Clear
End If
If tvwPNR.Nodes.Count > 0 Then
tvwPNR.Nodes.Clear
End If
Call DisplayAllPNRS
txtRelocNumber.SelStart = 0
txtRelocNumber.SelLength = Len(txtRelocNumber.text)
txtRelocNumber.Refresh
txtRelocNumber.SetFocus
Exit Sub
Else
cmdCreateTicket.Enabled = True
End If
recPNR.Close
gblnSearch = False
Screen.MousePointer = vbNormal
PROC_EXIT:
On Error Resume Next
Set recPNR = Nothing
Set cmdSearchForPnr = Nothing
Exit Sub
PROC_ERR:
Call New_Error_Handler(MODULE_NAME, PROCEDURE_NAME, Err.Number, Err.Description)
Resume PROC_EXIT
End Sub