Arg81
Well-known member
I have a search form, and another form which displays the results from that search.
At the moment on the search form there are about 8 radio buttons (each one is a different search, i.e. search all, search ID, search description, etc)
I have set up Global Parameters using a module in my project.
On the search form, if a search is selected, I set one of the Parameters to be true, and all the others to be false. If a value is needing to be set, I also save this as one of the other parameters.
It then opens the main form.
So for example, on the search form, if I select Search By ID and fill in the ID in the textbox, and then press the Search Button, :
The search form closes and the main form opens, and in the form_load when it loads the data, it checks what search parameter is set to True. For example:
Now, although it works perfectly, it seems a little messy. Is there a better way to have a Parent / Child search form scenario, without the need of Global Parameters?
The reason I ask, is if I have to add new searches, I have to add another parameter, I have to make sure it's getting recorded OK from the search form and then also remember to make sure that search gets loaded on the main form!!
Sorry for the long-winded post. It's just I've always done a search form this way, and was thinking that there must be an easier way in VS2005 !
At the moment on the search form there are about 8 radio buttons (each one is a different search, i.e. search all, search ID, search description, etc)
I have set up Global Parameters using a module in my project.
On the search form, if a search is selected, I set one of the Parameters to be true, and all the others to be false. If a value is needing to be set, I also save this as one of the other parameters.
It then opens the main form.
So for example, on the search form, if I select Search By ID and fill in the ID in the textbox, and then press the Search Button, :
VB.NET:
Private Sub mnuSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuSearch.Click
If Me.rbID.Checked = True Then
Me.GetID()
ElseIf Me.rbRecipe.Checked = True Then
Me.RecipeID()
ElseIf Me.rbSieve.Checked = True Then
Me.SieveID()
[COLOR="SeaGreen"]'there are LOTS more here, I've just cut them down![/COLOR]
End If
End Sub
Private Sub GetID()
If Me.txtID.Text = Nothing Then
MessageBox.Show("Please enter ID you are searching for", "Enter ID", MessageBoxButtons.OK, MessageBoxIcon.Hand)
Me.txtID.Focus()
Else
varSearchID = True
varSearchRecipeID = False
varSearchSieveTypeID = False
varSearchLast20 = False
varSearchAll = False
varSearchInProd = False
varSearchDescription = False
varID = Me.txtID.Text
Me.Close()
End If
End Sub
The search form closes and the main form opens, and in the form_load when it loads the data, it checks what search parameter is set to True. For example:
VB.NET:
Try
If varSearchID = True Then
Me.MyTableAdapter.FillByID(Me.MyDataSet.MyTable, varID)
ElseIf varSearchRecipeID = True Then
Me.MyTableAdapter.FillByRecipeID(Me.MyDataSet.MyTable, varRecipeID)
ElseIf varSearchSieveTypeID = True Then
Me.MyTableAdapter.FillBySieveTypeID(Me.MyDataSet.MyTable, varSieveTypeID)
End If
...
...
End Try
Now, although it works perfectly, it seems a little messy. Is there a better way to have a Parent / Child search form scenario, without the need of Global Parameters?
The reason I ask, is if I have to add new searches, I have to add another parameter, I have to make sure it's getting recorded OK from the search form and then also remember to make sure that search gets loaded on the main form!!
Sorry for the long-winded post. It's just I've always done a search form this way, and was thinking that there must be an easier way in VS2005 !
Last edited: