Cascading ComboBox to ListBox to Calculation

GraemeG

Registered User.
Local time
Today, 21:03
Joined
Jan 22, 2011
Messages
212
Hi,

I have a form with the following:

Combobox One - cboFloorCode (cascades to another combo)
Private Sub cboFloorCode_AfterUpdate()
Dim strSource As String
strSource = "SELECT SORdescription " & _
"FROM SORV4_BR_FLOOR " & _
"WHERE SORshortdesc = '" & Me.cboFloorCode & "' ORDER BY SORshortdesc"
Me.cboFloorDesc.RowSource = strSource
Me.cboFloorDesc = vbNullString
End Sub

Combobox Two - cboFloorDesc (cascades to a listbox)
Private Sub cboFloorDesc_AfterUpdate()
Dim strSource As String
strSource = "SELECT baseprice " & _
"FROM SORV4_BR_FLOOR " & _
"WHERE SORdescription = '" & Me.cboFloorDesc & "' ORDER BY SORdescription"
Me.txtFloorBase.RowSource = strSource
Me.txtFloorBase = vbNullString
End Sub

But then in this txtFloorBase is a cost which then I want another txtbox to calculate this cost times the quantity entered in another textbox.

Thanks
 
I have solved this by doing a query then using the control source to view the query. However how can I get the calculation to refresh live on update. i.e. it updates once the form is closed and reopened.
Thanks
 
What currently works.

What doesn't work.

What errors do you have and where.

What are the names of the Text Boxes you want to use in the calculation.

Where do you want that result stored.

Is every thing Bound. If not what is and what isn't.
 
We posted at the same time.

To refresh the screen use

Me.Dirty = False
Me.Refresh

Not sure where you are going to put this but it needs to be done immediately after the Text Boxes have been completed. Most likely a Before Update Event
 
What currently works.

What doesn't work.

What errors do you have and where.

What are the names of the Text Boxes you want to use in the calculation.

Where do you want that result stored.

Is every thing Bound. If not what is and what isn't.

No not everything is bound.
I have the first combobox (cboFloorCode) unbound source Table:Field
Second combobox is bound to a control source in a table but the rowsource is from a different table. This second combo is cascaded from the first combo selection.
I then have two other listboxes both unbound one is updated from the comboselection. The other looks at a query field it all works a treat.
(The query field is based upon a response from a bound txtbox entry on the form) However the txtbox that looks at the query only updates once the form is closed and reopened is there any way of updating it from the entry in the txtbox which updates the table/query?
Thanks
 
No not everything is bound.
I have the first combobox (cboFloorCode) unbound source Table:Field
Second combobox is bound to a control source in a table but the rowsource is from a different table. This second combo is cascaded from the first combo selection.
I then have two other listboxes both unbound one is updated from the comboselection. The other looks at a query field it all works a treat.
(The query field is based upon a response from a bound txtbox entry on the form) However the txtbox that looks at the query only updates once the form is closed and reopened is there any way of updating it from the entry in the txtbox which updates the table/query?
Thanks

Got it - me.refresh on enter!
 
It would be better with Me.Refresh in the Before Update Event of that Text Box.

Enter may not catch all situations.
 

Users who are viewing this thread

Back
Top Bottom