If Form Loaded Then....Question
I am working on a project that currently has 4 Forms
1. frmMain (MDIForm) - with options menu to launch other 3 forms
2. frmContactList (MDIChild = True)
3. frmCompanyList(MDIChild = True)
4. frmOptions(MDIChild = False)
The Startup Object is Sub Main: frmMain.Show
The Menu on frmMain has a command button for forms 2-4 with the following code:
Private Sub Command1_Click(Index As Integer)
Dim FormContactList As frmContactList
Dim FormCompanyList As frmCompanyList
Select Case Index
Case 0
Set FormContactList = New frmContactList
FormContactList.Show
Case 1
Set FormCompanyList = New frmCompanyList
FormCompanyList.Show
Case 2
frmOptions.Show
End Select
End Sub
frmOptions has options on 2 tabs, one for frmContactList and one for frmCompanyList. The options Are FontSize(cbo), Gridlines(chk), allow column reorder(chk). It also has 3 commnad buttons, OK Cancel and Apply.
I am using A standard Module, UserOptions, with Property Let/Get Statements for each Option and For Each Form (ie CONLST_FONTSIZE, CMPLST_FONTSIZE.......) These are Set on Startup From an ini File. The frmOptions has Private Variables m_CONLST_FONTSIZE, m_CMPLST_FONTSIZE..... that are set from the Standard Module UserOptions values. If the user hits CANCEL the form is unloaded. If the user hits APPLY the Properties in the Standard Module UserOptions are updated from the Private Variables in frmOptions. If he hits OK, the same thing as APPLY but the form closes.
I got everything working fine except that I an open frmContactList or open frmCompanyList to be updated on Apply/OK Click if they are open. I may have more than one of each open.
I tried placing this in the frmOptions cmdButton_Click(Index As Integer) Sub for the Apply Button(Index 0) and the OK Button (Index 2):
If frmContactList.Count > 0 Then
For Each FormContactList In frmContactList
frmContactList.RefreshOptions (Calls code in the user control containing the ListView1...ListView1.Refresh)
Next FormContactList
End If
The problem is that If there is no frmContactList that is open, when I click APPLY, a form opens. I place Debug.Print frmContactList.Count Within the APPLY Click Event. It prints out 1 even though there are no open forms. All that I have done in the cmdButton_Click Event of the menu Control on frmMain(MDIForm) is write Dim FormContactList As frmContactList but did not write Set FormContactList = New frmContactList Until the click event(See Above Code). Why is the frmContactList.Count = 1 Before I open a form? How can I get around all This?
Any Help will be greatly appreciated. Thanks in Advance.
I am working on a project that currently has 4 Forms
1. frmMain (MDIForm) - with options menu to launch other 3 forms
2. frmContactList (MDIChild = True)
3. frmCompanyList(MDIChild = True)
4. frmOptions(MDIChild = False)
The Startup Object is Sub Main: frmMain.Show
The Menu on frmMain has a command button for forms 2-4 with the following code:
Private Sub Command1_Click(Index As Integer)
Dim FormContactList As frmContactList
Dim FormCompanyList As frmCompanyList
Select Case Index
Case 0
Set FormContactList = New frmContactList
FormContactList.Show
Case 1
Set FormCompanyList = New frmCompanyList
FormCompanyList.Show
Case 2
frmOptions.Show
End Select
End Sub
frmOptions has options on 2 tabs, one for frmContactList and one for frmCompanyList. The options Are FontSize(cbo), Gridlines(chk), allow column reorder(chk). It also has 3 commnad buttons, OK Cancel and Apply.
I am using A standard Module, UserOptions, with Property Let/Get Statements for each Option and For Each Form (ie CONLST_FONTSIZE, CMPLST_FONTSIZE.......) These are Set on Startup From an ini File. The frmOptions has Private Variables m_CONLST_FONTSIZE, m_CMPLST_FONTSIZE..... that are set from the Standard Module UserOptions values. If the user hits CANCEL the form is unloaded. If the user hits APPLY the Properties in the Standard Module UserOptions are updated from the Private Variables in frmOptions. If he hits OK, the same thing as APPLY but the form closes.
I got everything working fine except that I an open frmContactList or open frmCompanyList to be updated on Apply/OK Click if they are open. I may have more than one of each open.
I tried placing this in the frmOptions cmdButton_Click(Index As Integer) Sub for the Apply Button(Index 0) and the OK Button (Index 2):
If frmContactList.Count > 0 Then
For Each FormContactList In frmContactList
frmContactList.RefreshOptions (Calls code in the user control containing the ListView1...ListView1.Refresh)
Next FormContactList
End If
The problem is that If there is no frmContactList that is open, when I click APPLY, a form opens. I place Debug.Print frmContactList.Count Within the APPLY Click Event. It prints out 1 even though there are no open forms. All that I have done in the cmdButton_Click Event of the menu Control on frmMain(MDIForm) is write Dim FormContactList As frmContactList but did not write Set FormContactList = New frmContactList Until the click event(See Above Code). Why is the frmContactList.Count = 1 Before I open a form? How can I get around all This?
Any Help will be greatly appreciated. Thanks in Advance.