gknierim
February 28th, 2000, 09:33 AM
I am confused as well as having a problem with .show, .hide, vbmodal, Load and Unload. Heres the situation. My main form (frmMain) is a MDI form. From the menu, I show the SelectParams form(MDIChild is False for all forms except Main) by saying:
private Sub mnuModelParameters_Click()
SelectParams.Show vbModal
End Sub
This window is a search criteria window for the next window it shows. When the user selects his criteria and clicks the OK button, I perform the following code:
private Sub OKButton_Click()
me.Hide
set fModelParams = new ModelParams
fModelParams.Top = 0
fModelParams.Left = 0
fModelParams.Width = 9120
fModelParams.Show vbModal
Unload me
End Sub
This hides(and later unloads) the search window and displays the ModelParams window. However, when the .show gets executed, it goes into the Load procedure of the ModelParams form. In the Load procedure of the ModelParam form, I open the database and search to see if any records exist. The problem is that if there are no records, the form still displays with no records and I do not want that. Below is the code I use in the Load event of that form:
private Sub Form_Load()
'Open database and get records ... blah blah)
If rs.BOF And rs.EOF then
MsgBox "No Model Families were found. Please retry your search criteria again.", vbInformation
rsRecCount = 0
me.Hide
else
LoadList
End If
End Sub
My question is the Me.Hide above is not executing and I have tried an Unload but that doesn't work either. Ideally, I would like to display the first window so that the user can do the search again if there are no records. I am so confused on the sequence of events of show, hide, load, and unload that I'm not sure what to do here. I have been playing with this for a day and cannot get this to work.
I would greatly appreciate any suggestions or explanations. Thanks.
private Sub mnuModelParameters_Click()
SelectParams.Show vbModal
End Sub
This window is a search criteria window for the next window it shows. When the user selects his criteria and clicks the OK button, I perform the following code:
private Sub OKButton_Click()
me.Hide
set fModelParams = new ModelParams
fModelParams.Top = 0
fModelParams.Left = 0
fModelParams.Width = 9120
fModelParams.Show vbModal
Unload me
End Sub
This hides(and later unloads) the search window and displays the ModelParams window. However, when the .show gets executed, it goes into the Load procedure of the ModelParams form. In the Load procedure of the ModelParam form, I open the database and search to see if any records exist. The problem is that if there are no records, the form still displays with no records and I do not want that. Below is the code I use in the Load event of that form:
private Sub Form_Load()
'Open database and get records ... blah blah)
If rs.BOF And rs.EOF then
MsgBox "No Model Families were found. Please retry your search criteria again.", vbInformation
rsRecCount = 0
me.Hide
else
LoadList
End If
End Sub
My question is the Me.Hide above is not executing and I have tried an Unload but that doesn't work either. Ideally, I would like to display the first window so that the user can do the search again if there are no records. I am so confused on the sequence of events of show, hide, load, and unload that I'm not sure what to do here. I have been playing with this for a day and cannot get this to work.
I would greatly appreciate any suggestions or explanations. Thanks.