Problems Using a Search Form

SikhSioux

Registered User.
Local time
Today, 08:02
Joined
Nov 13, 2003
Messages
22
I'm looking to create a form called 'frmMilkShakeIngredients' which allows you to add info about particular milkshakes and their ingredients. One of the fields (called 'cmbFruit') is a combo box filed which allows you to add a fruit. You can choose a fruit from a list (the source of the list is a table containing names of different fruit). If a fruit is typed in and is not in the list a new form (called 'frmFruits') opens. The 'frmFruits' form has a search button (called 'cmdOpenSearchForm') which should open a search form (called 'frmFruitSearch'). The search form allows you to search for a fruit and displays the fruit in the 'frmFruits' form. The user should be able to click on a button (called 'cmdCopyAndClose') which copies the fruit (found as result of the search) to the 'frmMilkShakeIngredients' form and then closes the 'frmFruits' form.

At the moment I have created the search button on the 'frmFruits' form. When I open this form manually I am able to successfully search for a particular fruit. However, when the 'frmFruits' form opens programmatically (as a result of a fruit not being in the list of fruits in the 'cmbFruit' field) and I click on the search button to open the search form the focus remains with the 'frmFruits' form, the search form cannot be made active as expected.

Below is my code for the NotInList event:

Private Sub cmbFruit_NotInList (NewData As String, Response As Integer)
DoCmd.OpenForm "frmFruit",,,,, acDialog
End Sub


Below is the code for OnClick event of the search button:

Private Sub cmdOpenSearchForm_Click()
On Error GoTo Err_cmdOpenSearchForm_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmFruitSearch"
DoCmd.OpenForm stDocName,,, stLinkCriteria
Forms!frmFruitSearch.SetFocus

Exit_cmdOpenSearchForm_Click:
Exit Sub

Err_cmdOpenSearchForm_Click:
MsgBox Err.Description
Resume Exit_cmdOpenSearchForm_Click

End Sub

Can anyone help me get the search form active as expected and also help me create a copy and close button ('cmdCopyAndClose') as mentioned in paragraph 1?

Cheers
 
If your search form and your combo box are based on the same table (tblFruits) then it's going to be obvious that the fruit does not exist in the table. If you set the autoexpand to true then the combo should find the fruit if it appears in the table.

If you set the limit to list property to Yes then they will only be allowed to pick from the list. If you give them access to add to the list you may find that your list will grow and grow. Your stock control on the types of fruits available should dictate what selections can be made. If you do not stock pinapple flavouring or pinapples syrup why let them pick / add pinapple to the list. This should be done as an administrative task.
 
I may be wrong, but shouldn't the acDialog setting be made in the designer properties for the form? acDialog should be changed to acWindowNormal or left blank since it is optional.

From what I remember, Dialog means that it's modal like a dialog box. Right?
 

Users who are viewing this thread

Back
Top Bottom