S
Sandy
The following are events on two combo boxes on a subform "NewJobsSubform",
the first sets the rowsource of the second and also sets a default value in
the second. The second event sets the value in the text box "Sell" to the
price associated with the RepProduct in cboRepProduct - collected from the
table "RepairProducts".
"Private Sub cboCatName_AfterUpdate()
On Error Resume Next
Me.cboRepProduct.RowSource = "SELECT RepairProduct.RepProduct FROM" & _
" RepairProduct WHERE CatName = '" & Me.cboCatName.Value & "' " & _
" ORDER BY RepProduct;"
Me.cboRepProduct = Me.cboRepProduct.ItemData(0)
Me.cboRepProduct.Requery
End Sub"
"Private Sub cboRepProduct_AfterUpdate()
On Error GoTo Err_cboRepProduct_AfterUpdate
Me!Sell = DLookup("SellPrice", "RepairProduct", "RepProduct = '" &
Nz([cboRepProduct], 0) & "'")
Me!Buy = DLookup("BuyPrice", "RepairProduct", "RepProduct = '" &
Nz([cboRepProduct], 0) & "'")
Exit_cboRepProduct_AfterUpdate:
Exit Sub
Err_cboRepProduct_AfterUpdate:
MsgBox Err.Description
Resume Exit_ProductID_AfterUpdate
End Sub"
The problem is that if a user accepts the default value inserted into
cboRepProduct, then the price is not inserted into textbox "Sell", if
however the user selects the drop-down menu and selects any value (even the
one that was default) the correct price is inserted into textbox "Sell".
I know that I can simply delete the line - 'Me.cboRepProduct =
Me.cboRepProduct.ItemData(0)' from the "cboCatName_AfterUpdate" event - but
I would like to keep it if possible.
How can I force the "Sell" textbox to be filled otherwise?
Sandy
the first sets the rowsource of the second and also sets a default value in
the second. The second event sets the value in the text box "Sell" to the
price associated with the RepProduct in cboRepProduct - collected from the
table "RepairProducts".
"Private Sub cboCatName_AfterUpdate()
On Error Resume Next
Me.cboRepProduct.RowSource = "SELECT RepairProduct.RepProduct FROM" & _
" RepairProduct WHERE CatName = '" & Me.cboCatName.Value & "' " & _
" ORDER BY RepProduct;"
Me.cboRepProduct = Me.cboRepProduct.ItemData(0)
Me.cboRepProduct.Requery
End Sub"
"Private Sub cboRepProduct_AfterUpdate()
On Error GoTo Err_cboRepProduct_AfterUpdate
Me!Sell = DLookup("SellPrice", "RepairProduct", "RepProduct = '" &
Nz([cboRepProduct], 0) & "'")
Me!Buy = DLookup("BuyPrice", "RepairProduct", "RepProduct = '" &
Nz([cboRepProduct], 0) & "'")
Exit_cboRepProduct_AfterUpdate:
Exit Sub
Err_cboRepProduct_AfterUpdate:
MsgBox Err.Description
Resume Exit_ProductID_AfterUpdate
End Sub"
The problem is that if a user accepts the default value inserted into
cboRepProduct, then the price is not inserted into textbox "Sell", if
however the user selects the drop-down menu and selects any value (even the
one that was default) the correct price is inserted into textbox "Sell".
I know that I can simply delete the line - 'Me.cboRepProduct =
Me.cboRepProduct.ItemData(0)' from the "cboCatName_AfterUpdate" event - but
I would like to keep it if possible.
How can I force the "Sell" textbox to be filled otherwise?
Sandy