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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem transfering totals from Form 1 to Form2

Status
Not open for further replies.

aageorge

Technical User
Jun 28, 2003
51
US
Hi,

I have a main form that pops up a form depending on what Line you select. The popup form is where the user puts in counts for different part numbers. I setup the following vbcode in the on close event of the popup form:

Forms![Main Form]![Pieces Run] = (Part1 + Part2 + Part3)

When the user closes the popup form, the idea is that Pieces_Run textbox is updated with the sum of all the part counts. It works fine the first time you do it, but if you try to enter different counts it shows the original sum. Eg:

First run:
Part1=10 Part2=10 Part3=10, Pieces_Run=30
Second run:
Part1=10 Part2=20 Part3=20, Pieces_Run=30 (should be 50)

How do I fix this problem.

 
This calculation needs to be tied to the triggering of an event. It sounds to me like you need the on_current event of the form. Just write your code there. If you need help, post another question.

Rollie E
 
You should be able to refer to the main forms text box from the subforms routine:
With a Save or exit or close button on the subform, then in that buttons click event you should be able to have:

private sub Click()
[Form_Main Form]!TextBox.Setfocus
[Form_Main Form]!TextBox.Text = Part1 + Part2 + Part3
DoCmd.Close
endsub
 
If you are using a text variable, "1"+"1"+"1" = "111"

You should at least use the val() function.


R
 
Hi,

I have a similar problem as the above, I am using the save buton to move the calculation to another form but my problem is that the value I need is rounded to the tenth position and when i moves the data to the new form it uses the actual calculation before the rounding I need it to move the rounded number any help would be appreciated.

I need it to send 34.6 what I get is 34.5666.
 
I believe there is a rounded function whose name is ROUND().

Even if there is not to round yourself just use this simple calculation

MyRound = (int((MyNumber + 0.5)* 10))/10

use 100 for two places and 1000 to three etc.


Rollie E
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top