Calculating fields in a form from combo fields

J

Jay

Hey all,
I know the typical response that I will see with this post is build a
query, but in this database, I need to limit the amount of queries I
have, and I know that what I want to do is possible using code, but
can't seem to word it right.

My situation is, I have a table for orders placed, and a table with
the part number and three amounts; shipping cost, wholesale cost, and
markup. On my orders form, I have a combo box that has all of the
fields from the part number table. When someone selects the part from
the list, I want a total cost appear, totalling the bound columns from
the combo box. The reason for this I do not want the person placing
the order to see the markup costs. I have created a code that updates
the cost field with one of the amounts, but when I try to add them all
together. This is what I have:

Private Sub partnumber_AfterUpdate()
Me.totalcost.Value = Me.partnumber.Column(2) +
Me.partnumber.Column(3) + Me.partnumber.Column(4)
End Sub

This takes the total from each field and combines then in the same
field box, i.e.
Shipping Wholesale Markup
$5.00 $349.00 $15.00

and displays it like this:
$534915.00 (all of the amounts side by side)

Any help would be appreciated
Jason
 
J

Jay

Hey Danny,
Those fields were all currencies, but this worked beautifully, thank
you so much, I am still relatively new to VB, and I keep forgetting how
important and helpful it is to define your values when initially
writing the code. Thanks again,
Jason
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top