Hi,
I have a form frmOrders which contains frmOrderDetails as subform. When I want to add a new product to order from frmOrderDetails by clicking Add product button, frmAdvancedSearch is opened. This contains an unbound text box called txtSearch and a list box called SearchList, which displays the search result (ProductID, ProductName) based on what it is typed in txtSearch text box.
Now I would like to make possible this: when I double-click a product from the list box, that product is added automatically to the order, by entering its ID to ProductID (Cod_Prod) field from frmOrderDetails.
Initially, I had this search code on the double-click event, which I think (and HOPE!) can be easily modified for my needs:
Private Sub SearchList_DblClick(Cancel As Integer)
On Error GoTo Err_SearchList_DblClick
Dim db As DAO.Database
Dim rst As DAO.Recordset
DoCmd.OpenForm "frmOrders"
DoCmd.Maximize
Set rst = Forms!frmOrders.Recordset.Clone
rst.FindFirst "[Cod_Com] = " & Me.SearchList
Forms!frmOrders.Bookmark = rst.Bookmark
DoCmd.Close acForm, Me.Name
Exit_SearchList_DblClick:
Exit Sub
Err_SearchList_DblClick:
MsgBox Err.Description
Resume Exit_SearchList_DblClick
End Sub
I think this can be modified to be used for entering the product ID into ProductID (Cod_Prod) field from sfrmOrderDetails, just unfortunately I'm not that good in coding, that's the reason why I'm needing help.
I have a form frmOrders which contains frmOrderDetails as subform. When I want to add a new product to order from frmOrderDetails by clicking Add product button, frmAdvancedSearch is opened. This contains an unbound text box called txtSearch and a list box called SearchList, which displays the search result (ProductID, ProductName) based on what it is typed in txtSearch text box.
Now I would like to make possible this: when I double-click a product from the list box, that product is added automatically to the order, by entering its ID to ProductID (Cod_Prod) field from frmOrderDetails.
Initially, I had this search code on the double-click event, which I think (and HOPE!) can be easily modified for my needs:
Private Sub SearchList_DblClick(Cancel As Integer)
On Error GoTo Err_SearchList_DblClick
Dim db As DAO.Database
Dim rst As DAO.Recordset
DoCmd.OpenForm "frmOrders"
DoCmd.Maximize
Set rst = Forms!frmOrders.Recordset.Clone
rst.FindFirst "[Cod_Com] = " & Me.SearchList
Forms!frmOrders.Bookmark = rst.Bookmark
DoCmd.Close acForm, Me.Name
Exit_SearchList_DblClick:
Exit Sub
Err_SearchList_DblClick:
MsgBox Err.Description
Resume Exit_SearchList_DblClick
End Sub
I think this can be modified to be used for entering the product ID into ProductID (Cod_Prod) field from sfrmOrderDetails, just unfortunately I'm not that good in coding, that's the reason why I'm needing help.