PC Review


Reply
Thread Tools Rate Thread

Automatic updating of a field

 
 
Ciquo
Guest
Posts: n/a
 
      18th Oct 2006
I am in the process of constructing a database, and have run into a
problem my limited know-how does not let me solve.

I have a field "line-item-cost" This field is the calculated product of
three other fileds from different tables. the "Price" of a product from
the PRODUCT table multiplied by "Quantity ordered" in the ORDERLINE
table then subtract a "Discount" a percent value form a CUTOMER table.
line-item-cost represents the final cost of a pirticular order. my
desired result is the orderline field to be automaticly calculated upon
the creation of an ORDERLINE record, which consists of the the
order_no, product_no and quatitiy ordered and the line-item-cost.

I have created a update query that does this quite easily, and
currently have it setup to automaticly run after the data entry form
for ORDERLINE is closed. this solution does not fuction the way i want
it to. first running teh querry affects all line-item-cost records,
when i only need it to affect an edited or created record, second i
want the query to run silently so to speak, withought the prompts
access gives you. lastly if discount is changed the query will affect
all records affected by that discount, new or otherwise, an update to
discount should only affect new records affected by that change not
prior ones.

Is there a way to acheive the results i desire with an update query or
is there a better solution to my problem. thank you.

 
Reply With Quote
 
 
 
 
Rick Brandt
Guest
Posts: n/a
 
      18th Oct 2006
Ciquo wrote:
> I am in the process of constructing a database, and have run into a
> problem my limited know-how does not let me solve.
>
> I have a field "line-item-cost" This field is the calculated product
> of three other fileds from different tables. the "Price" of a product
> from the PRODUCT table multiplied by "Quantity ordered" in the
> ORDERLINE table then subtract a "Discount" a percent value form a
> CUTOMER table. line-item-cost represents the final cost of a
> pirticular order. my desired result is the orderline field to be
> automaticly calculated upon the creation of an ORDERLINE record,
> which consists of the the order_no, product_no and quatitiy ordered
> and the line-item-cost.
>
> I have created a update query that does this quite easily, and
> currently have it setup to automaticly run after the data entry form
> for ORDERLINE is closed. this solution does not fuction the way i want
> it to. first running teh querry affects all line-item-cost records,
> when i only need it to affect an edited or created record, second i
> want the query to run silently so to speak, withought the prompts
> access gives you. lastly if discount is changed the query will affect
> all records affected by that discount, new or otherwise, an update to
> discount should only affect new records affected by that change not
> prior ones.
>
> Is there a way to acheive the results i desire with an update query or
> is there a better solution to my problem. thank you.


What you should be doing is storing in your ORDERLINE table all three values
that are used as operands in the equation and then calculate that result
on-the-fly wherever you need it. The result is not saved anywhere.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


 
Reply With Quote
 
David F Cox
Guest
Posts: n/a
 
      18th Oct 2006
you have to identify the record you want updated by its key, so the key
should be in the WHERE clause (or Criteria cell in query design view.)

"Ciquo" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I am in the process of constructing a database, and have run into a
> problem my limited know-how does not let me solve.
>
> I have a field "line-item-cost" This field is the calculated product of
> three other fileds from different tables. the "Price" of a product from
> the PRODUCT table multiplied by "Quantity ordered" in the ORDERLINE
> table then subtract a "Discount" a percent value form a CUTOMER table.
> line-item-cost represents the final cost of a pirticular order. my
> desired result is the orderline field to be automaticly calculated upon
> the creation of an ORDERLINE record, which consists of the the
> order_no, product_no and quatitiy ordered and the line-item-cost.
>
> I have created a update query that does this quite easily, and
> currently have it setup to automaticly run after the data entry form
> for ORDERLINE is closed. this solution does not fuction the way i want
> it to. first running teh querry affects all line-item-cost records,
> when i only need it to affect an edited or created record, second i
> want the query to run silently so to speak, withought the prompts
> access gives you. lastly if discount is changed the query will affect
> all records affected by that discount, new or otherwise, an update to
> discount should only affect new records affected by that change not
> prior ones.
>
> Is there a way to acheive the results i desire with an update query or
> is there a better solution to my problem. thank you.
>
>



 
Reply With Quote
 
JK
Guest
Posts: n/a
 
      18th Oct 2006
Ciquo,

The way I handle this is by using the AfterUpdate events in the relevant
fields in the order table.

When you select (or change) the product:

Price = Dlookup() in the product table
Discount=DLookup() in the customer table
and calculate Line-Item-cost

If you brought the price and discount into the order form, you simply
recalculate again when you change the quantity, or any other filed that
affects you line total, otherwise you Dlookup them again.

Regards/JK


"Ciquo" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I am in the process of constructing a database, and have run into a
> problem my limited know-how does not let me solve.
>
> I have a field "line-item-cost" This field is the calculated product of
> three other fileds from different tables. the "Price" of a product from
> the PRODUCT table multiplied by "Quantity ordered" in the ORDERLINE
> table then subtract a "Discount" a percent value form a CUTOMER table.
> line-item-cost represents the final cost of a pirticular order. my
> desired result is the orderline field to be automaticly calculated upon
> the creation of an ORDERLINE record, which consists of the the
> order_no, product_no and quatitiy ordered and the line-item-cost.
>
> I have created a update query that does this quite easily, and
> currently have it setup to automaticly run after the data entry form
> for ORDERLINE is closed. this solution does not fuction the way i want
> it to. first running teh querry affects all line-item-cost records,
> when i only need it to affect an edited or created record, second i
> want the query to run silently so to speak, withought the prompts
> access gives you. lastly if discount is changed the query will affect
> all records affected by that discount, new or otherwise, an update to
> discount should only affect new records affected by that change not
> prior ones.
>
> Is there a way to acheive the results i desire with an update query or
> is there a better solution to my problem. thank you.
>



 
Reply With Quote
 
Ciquo
Guest
Posts: n/a
 
      18th Oct 2006
David F Cox wrote:
> you have to identify the record you want updated by its key, so the key
> should be in the WHERE clause (or Criteria cell in query design view.)
>
> "Ciquo" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >I am in the process of constructing a database, and have run into a
> > problem my limited know-how does not let me solve.
> >
> > I have a field "line-item-cost" This field is the calculated product of
> > three other fileds from different tables. the "Price" of a product from
> > the PRODUCT table multiplied by "Quantity ordered" in the ORDERLINE
> > table then subtract a "Discount" a percent value form a CUTOMER table.
> > line-item-cost represents the final cost of a pirticular order. my
> > desired result is the orderline field to be automaticly calculated upon
> > the creation of an ORDERLINE record, which consists of the the
> > order_no, product_no and quatitiy ordered and the line-item-cost.
> >
> > I have created a update query that does this quite easily, and
> > currently have it setup to automaticly run after the data entry form
> > for ORDERLINE is closed. this solution does not fuction the way i want
> > it to. first running teh querry affects all line-item-cost records,
> > when i only need it to affect an edited or created record, second i
> > want the query to run silently so to speak, withought the prompts
> > access gives you. lastly if discount is changed the query will affect
> > all records affected by that discount, new or otherwise, an update to
> > discount should only affect new records affected by that change not
> > prior ones.
> >
> > Is there a way to acheive the results i desire with an update query or
> > is there a better solution to my problem. thank you.
> >
> >How do i identify the record, specifcly the "current" record so that that record is teh only one affected by the querry???


 
Reply With Quote
 
Ciquo
Guest
Posts: n/a
 
      18th Oct 2006
How do i reference the current record ??

David F Cox wrote:
> you have to identify the record you want updated by its key, so the key
> should be in the WHERE clause (or Criteria cell in query design view.)
>
> "Ciquo" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >I am in the process of constructing a database, and have run into a
> > problem my limited know-how does not let me solve.
> >
> > I have a field "line-item-cost" This field is the calculated product of
> > three other fileds from different tables. the "Price" of a product from
> > the PRODUCT table multiplied by "Quantity ordered" in the ORDERLINE
> > table then subtract a "Discount" a percent value form a CUTOMER table.
> > line-item-cost represents the final cost of a pirticular order. my
> > desired result is the orderline field to be automaticly calculated upon
> > the creation of an ORDERLINE record, which consists of the the
> > order_no, product_no and quatitiy ordered and the line-item-cost.
> >
> > I have created a update query that does this quite easily, and
> > currently have it setup to automaticly run after the data entry form
> > for ORDERLINE is closed. this solution does not fuction the way i want
> > it to. first running teh querry affects all line-item-cost records,
> > when i only need it to affect an edited or created record, second i
> > want the query to run silently so to speak, withought the prompts
> > access gives you. lastly if discount is changed the query will affect
> > all records affected by that discount, new or otherwise, an update to
> > discount should only affect new records affected by that change not
> > prior ones.
> >
> > Is there a way to acheive the results i desire with an update query or
> > is there a better solution to my problem. thank you.
> >
> >


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
updating field based on other field - On current doesn't do it? efandango Microsoft Access Form Coding 3 17th Mar 2008 05:58 PM
Updating field in table based on calculated field in form =?Utf-8?B?TWFjTnV0MjAwNA==?= Microsoft Access 4 21st May 2007 07:27 PM
Updating linked child field to master field value on data entry isobel26@gmail.com Microsoft Access Form Coding 1 18th Oct 2006 03:55 AM
automatic updating filename field header word 2007 =?Utf-8?B?Z3V5ZGVieWw=?= Microsoft Word Document Management 1 16th Oct 2006 01:00 AM
Updating a field in one table with the contents of a field in anot =?Utf-8?B?RG9ub3Zhbg==?= Microsoft Access Queries 1 16th Sep 2006 09:23 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:23 PM.