AfterUpdate Question

J

John

I clearly don't know how to do what I want

I am building a simple program to calculate total cost of an item
based on my cost plus profit plus shipping equals total

I have a POUNDS table with ShipPound and ShipRate (will later fill in
values from UPS) the ShipPound field is the Index

I have an ITEMS table with (among others) ItemPound and ItemRate

I used the Relationship setter to set a link between ShipPound and
ItemPound in the two tables

What I want (as a first step toward later calculation) is to enter the
item's weight in ItemPound on the form, and then have ItemRate loaded
from the pounds table

I used the Expression builder in the AfterUpdate function, which gave
me (the items table is the basis for the form, so is loaded/active)

=[ItemRate]=[Pounds]![ShipRate]

When I enter a value into ItemPound on the form, I do not have the
value from ShipRate loaded into ItemRate

I get an error... what am I doing wrong?

Thanks, John
 
B

Bob Quintal

John said:
I clearly don't know how to do what I want

I am building a simple program to calculate total cost of an item
based on my cost plus profit plus shipping equals total

I have a POUNDS table with ShipPound and ShipRate (will later fill
in values from UPS) the ShipPound field is the Index

I have an ITEMS table with (among others) ItemPound and ItemRate

I used the Relationship setter to set a link between ShipPound and
ItemPound in the two tables

What I want (as a first step toward later calculation) is to enter
the item's weight in ItemPound on the form, and then have ItemRate
loaded from the pounds table

I used the Expression builder in the AfterUpdate function, which
gave me (the items table is the basis for the form, so is
loaded/active)

=[ItemRate]=[Pounds]![ShipRate]

When I enter a value into ItemPound on the form, I do not have the
value from ShipRate loaded into ItemRate

I get an error... what am I doing wrong?

Thanks, John
It's not clear to me if you mean the AfterUpdate Event of the Form or
of the ItemRate textbox.It should be the textbox event.

Second, even though you set a relationship, that relationship must be
implemented in a query. You imply that the form is built on the
table, not a query, so the relationship is not being used.

Thirdly, the query will enforce the relationship based on the value
of the ItemPounds field in its table when the form is opened.
cghanging the value will not necessarily cause the relationship to
jump to the newly entered value until the form is closed, reopened,
or otherwise requeried.

Fourthly, unless there is an exact match from ItemPiounds to
ShipPounds, the relationship will not resolve correctly,

In passing, the text of the error message is very useful to the
readers of this group, you should include it in your posts.

You would be much better off to replace your code with

=[ItemRate]=Dlookup("[ShipRate]", "Pounds", "shippound = " &
me.Pounds) -- assuming ShipPound is a numeric type field

Keep us informed of how you make out.
 
M

Mike Painter

John said:
I clearly don't know how to do what I want

I am building a simple program to calculate total cost of an item
based on my cost plus profit plus shipping equals total

I have a POUNDS table with ShipPound and ShipRate (will later fill in
values from UPS) the ShipPound field is the Index

I have an ITEMS table with (among others) ItemPound and ItemRate
Ther is no need for ItemRate, that should come from your Pounds table.
I used the Relationship setter to set a link between ShipPound and
ItemPound in the two tables
Yes.

What I want (as a first step toward later calculation) is to enter the
item's weight in ItemPound on the form, and then have ItemRate loaded
from the pounds table
What later calculations?



Make sure these fields are in the query that the form uses and just place
Pounds.ShipRate on the form
 

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