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

Passing a value from a calculated feild to a different form.

Status
Not open for further replies.

Wexus6

Programmer
Jul 18, 2000
6
US
I have a calculated feild at the bottom of my form that receives its value from a subform. This textbox is calulating total hours from the subform. When the user closes this form, I want to pass this calculated (sum) value to another open form. This is all easy to do accept for the following problem. If the user enters a number into the subform and hits close before leaving the record on the subform, the value isn't calculated in the calculated (sum)feild. <br>I've tried any number of work arounds. When I save from the toolbar, the feild is calculated and the value is passed. <br>So I've tried both docmd.accmdsave and docmd.accmdrefresh <br>to try do update the calculated feild before the form closes, still no luck. It always passes the value that was in the calculated feild before the update. I've spent 2 days on this problem and would be very thankfull of any help you can provide. I can also email the file to anyone interested in helping me solve this.<br>Thanks<br>Wes
 
if you have removed the form's Close button (set it's property to No), and use a command button to close the form, you can use as part of the close routine:<br><br>&nbsp;If Me.Dirty Then<br>&nbsp;' if necessary code to ensure your calculation is done<br>&nbsp;DoCmd.RunCommand acCmdSaveRecord<br>&nbsp;End If<br>&nbsp;DoCmd.Close<br><br>PaulF
 
Thank you for your suggestion. Here is the code I tried.<br><br>Private Sub Close_Click()<br>Dim strTest as String<br>If Me.Dirty then<br>strTest=me.time<br>DoCmd.Runcommand acCmdSaveRecord<br>End If<br>Docmd.Close<br>End Sub<br><br>Whenever The accmdsaverecord is inserted, strTest returns a null value.<br>If I remove acCmdSaveRecord strTest is equeal to the previous value of the calculated feild. <br>IE. strTest=207 me.time=208<br>I tried putting acCmdSaveRecord before and after strTest=me.time.<br>No Difference. <br>Any other ideas?<br>Thanks<br>Wes
 
Well, I'm not too sure what is going on.&nbsp;&nbsp;If you want, you can e-mail me the file (Access 97 only) at&nbsp;&nbsp;&nbsp;<br><br><A HREF="mailto:paul.fantacci@baesystems.com">paul.fantacci@baesystems.com</A><br><br>If I have a chance I'll look at it and see if I can help you<br><br>PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top