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
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