Pulling data from another table using VB

J

james

Hi,
I have a database that has two tables.
1 is my customer details.
2 is wholesale price.

Table 1 has a field called IAGBP and IAGBPMargin
Table 2 has a field called IAGBP also.
I want to link Table1 so that it takes the value of IAGBP in Table 2 and
adds the IAGBPMargin and puts the resultant figure into IAGBP in Table 1.

I am using the following code but the debug stops at C. I think my code for
that is wrong.

Also the only way I know to do this is to attach it to a button. Is there a
better way to get this figure to constantly update Table1 whenever I update
my wholesale price or margin price?

Private Sub Command14_Click()
Dim A As Integer
Dim B As Integer
Dim C As Integer


A = IAGBP.Value
B = IAGBPMargin.Value
C = Table2.IAGBP.Value

IAGBP.Value = (B / 10000) + C

End Sub
 
R

Rob Wills

Hi,
if the field's value is derived, why do you need to store it in the table?
Can't you just derive it in a query and then use your query instead of the
table?
 

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