Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Record values made by product of 2 other fields

Status
Not open for further replies.

Only1Abhi

Technical User
Jan 26, 2003
77
0
0
GB
Hi People!

I posted this problem years ago!
I searched for the thread but couldn't find it!


So... I'm posting it again!
Hoping access professionals can help out!


---------------------------------------------SCENARIO-------------------------
I have a table called tblTransaction.
In the tables, there are many fields but 3 in question right now:


Amount
Qty
Total



----------------------------------------------PROBLEM-------------------------
I want the Total field's value to be automated. It should depend on the Amount and Qty fields like this:

Total = Amount * Qty


I want this value to be stored in the table tblTransaction and NOT JUST viewed on my form frmTransaction.

-----------------------------------------------PROBLEM (Updated)----------
I have got the Total field to have the automated value. I did this by creating a hidden textbox in my form, which has the control source of "=Amount*Qty". Then in the BeforeUpdate Event of the form, I entered:

Me.txtTotal = Me.txtCalc (where txtTotal is the Total textbox and txtCalc is the hidden textbox's name).

But when I Update the Amount or Qty value, the 'Total' textbox (txtTotal) does not update INSTANTLY. Only the hidden texbox (txtCalc) is updated. I have to go to the next record, and then back to the same, previous record to see the update value. I need the update to be INSTANT.

Can anyone please please help me?
This problem is bugging me for quite some time!
Many thanks!


Can anyone please help?
I'm sure there is a solution but can't remember how!

Many thanks!
Regards,
Abhi!

 
Hi

By default all changes in a bound form are saved when you move to next record, not before, but you can force a save using DoCmd.RunCommand acCmdSaveRecord

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
this is what I done.

Still not working though! :(


Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.txtTotal = Me.txtCalc
DoCmd.RunCommand acCmdSaveRecord
End Sub
 
Hi

It would be more appropriate to put the save command in the after update evnt of each control (Amount and Qty), becuase the before update event of teh form fires just befor teh data is saved anyway!

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Magic...
Magic...

It works!

Thanks millions, billions and gazillions.


Kenray is the Don! ;o)

Thank You Very Much.

Kind Regards,
Abhi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top