relating to other fields..

What's the value displayed in Text21, are you sure the value you're looking for is in Text21, where does the value for Text21 come from?
 
it's doing a calculation there from the control source, the text21....
 
Post the calculation, is this a total in the subform
 
the calculation is =[t1]-[t2], this is text21 in a subform. so I'm wanting this value to be copied to a text box in the main form when it changes everytime...
 
How many records are in the subform for the first record of the main form?
 
It's taking too long to download, you need to compact and Zip it, but I suspect you have a later version than me anyway. Try posting a 97ver
 
it is zipped, it's half a meg lol. that's everything in it :)

um, how to convert to access 97 from XP?
 
I'll give you a 0 for not following directions. Get rid of ALL the setFocus code! Get rid of the .text property references! You need only ONE line of code to set the value. I removed the extraneous code and removed the .text property references and the button worked as intended.

However, the problem still remains that what you are doing is really poor practice. There is nothing that can force your user to push the update the total button whenever he updates the data in the subform. The order total should ALWAYS be calculated on the fly in a query as you need it. That way it will ALWAYS be accurate. Your way leaves the accuracy in doubt. To be even mildly certain of accuracy, you would need to use code in the subform's AfterUpdate event to update the total on the main form. That way at least it would happen automatically every time a subform record changed.
 
excuse me pat for sticking my beak in

the field text21 that tech refers to is in the subform footer

it gets its value from the query that the sub form is based on and
as such always reflects the order total based on
what was ordered and is always accurate

i know this because it comes from a sample db that was posted
to tech by me for him to experiment with.
 
Have to disagree with you here bj, the query is not returning the correct value untill the record is saved and the form re-queried, command 161 has to be pressed twice after a new record has been created in the subform unless the user tabs to a new blank record in the subform.
 
well, the reason I HAVE to use the .setfocus is because VBA then says that the control needs to be focused first otherwise it will produce an error, ALL THE TIME.

I tried taking away the .text and using the .value but that didn't make any difference for some reason, just diplayed £0.00

I did do the [t1]-[t2] in the order total but of course, that doesn't write it to the order form table.

unless I use VBA for the order total text box, but then, what I use the lost focus propery or what so it updates when the amount payable value has been updated in the subform?
 
it still don't work! :(

Private Sub Order_Total_Click()


Code:
Dim x As Currency
Dim y As Currency

Me![PurchasesSubForm]![T1].SetFocus
x = Me![PurchasesSubForm]![T1].Value

Me![PurchasesSubForm]![T2].SetFocus
y = Me![PurchasesSubForm]![T2].Value

Dim calc As Currency

calc = x - y

cmdrefresh_Click

End Sub

it still shows £0.00! even if I use the .text property
 
You need to study the replies
Me.txtTot = Me![PurchasesSubForm]![Text21]
where txtTot is total order renamed, the rest of your code is not required, but you need to save/update the changes to the subform first
 
U R THE MAN!! Thank-you soo much :) o, u just made a great start to the day before uni :)

*kisses and hugs* lol :)

so, how would I tell it to update that text box in the main form automatically if the values change on the subform OR if they have moved from 1 record to another?


I tried using the form_oncurrent but that makes the value 0.00:

Code:
Order_Total_Click

this is in the form_oncurrent..... but doesn't work, so i deleted it...
 
Last edited:
Rich you would need to go to the thread in the forms
section of this great site to get the whole background of
what we are talking about.
i dont know how to get you there but it does make interesting
reading.it was posted by me on 2/02/2003
i think i might just pull my head in at this stage
 

Users who are viewing this thread

Back
Top Bottom