By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,654 Members | 1,842 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,654 IT Pros & Developers. It's quick & easy.

How do I update textbox on Mainform on close of dialog window?

P: 4
I am building in Access 2013

I am using Navigation forms.

My main forms is frm_orders
- It has the field (bound) txtOrderTotal

My subform is frm_orderdetails
- It has the (unbound) field txtSubTotal

My dialog form to add items to order details is frm_AddItem
- It has cboProduct, txtUnitPrice, txtQty

Currently working - When I add a new item in my popup form and save it adds the item to the subform and changes the txtSubTotal

What I can't seem to do on close of the frm_AddItem is take the txtSubTotal from the subform and place it in txtOrderTotal on the main form.

I've tried accessing the text box via normal method Forms!frm_order!txtOrderTotal and Me.txtOrderTotal but vba just throughs a wobbly saying it can't find the field.

Is it because I am using Navigation forms.

Attached Images
File Type: jpg naviation_forms.jpg (20.4 KB, 539 views)
Jan 15 '14 #1
Share this Question
Share on Google+
11 Replies

Expert Mod 5K+
P: 5,397
1) Why?
2) show the formula/code you are using. Please format using the [Code/] button.
Jan 15 '14 #2

Expert Mod 15k+
P: 31,487
I suspect you need to tell it to requery.
Jan 15 '14 #3

Expert Mod 5K+
P: 5,397
Neo is more than likely correct; however, the navigation control has an unusual property and we need to see the refering formula/code.

If OP will search on ZMBD and "Navigation Control" I've covered this before... I've made two such posts that cover the basics of using the Navigation Control.
Jan 16 '14 #4

P: 4
I was planning on having a Total field in the Orders Table so I could call upon it throughout the database which is why I wanted to populate that field from the field in the subform.

I have decided to get rid of the Total field and I will instead calculate the total as and when I need it by adding line items in order details table as and when I need it.

I am finding Navigation forms frustrating at times as searching around on the web mainly produces non navigation form coding which doesn't work.

I have added your link to my delicious links thanks zmbd, and did the same for the other post you helped me with here on nav forms
Jan 17 '14 #5

Expert Mod 5K+
P: 5,397
ah... something just occured to me...
the new tempvar available to ACC2010
[]tempvars object [/url]

I've only been playing with these for a very short while. The object stays stable until you remove it or the session closes, can be used in a query, and is one of the very few objects that both the Macro and VBA can both workwith.
Here's a thread that goes over modifiying an exsisting code to to work with it... really straight forward:

What I see here, to avoid the nasty navigationsubform reference is to create the variable and from the subform store your value there and the set the controlsource of your unbound textbox to the tempvar...

and Thank You (^_^)!
Jan 17 '14 #6

Expert Mod 15k+
P: 31,487
I believe TempVars persist beyond the closing of the session. They are available for the life of the Access Application they are set in, or at least until the database is closed.
Jan 18 '14 #7

Expert 5K+
P: 8,634
Temporary Variables are Global and will remain in memory until the Database is closed which is why Temporary Variables should be removed when you are finished using them (RemoveTempVar for individual removal/RemoveAllTempVars collectively).
Jan 18 '14 #8

Expert Mod 5K+
P: 5,397
I may have the wrong term here.
In my mind for Access a session starts when the user opens the application and ends when the user closes the application.
I was not aware that the object would persist if the database was closed and the Access program remained open. I'll check that out in a momement.
Jan 18 '14 #9

Expert Mod 5K+
P: 5,397
(although not best practice)

I set up a series of tempvars.* within a database application.
Obviously, closing the Access Program removed the object; however, so did closing the database front end and the all-in-one database.
At no time did I clear the tempvars collection via code, and I state again, if you open it close it, if you set it clear it (^_^).

Thus, I stand by my concept of a session being the point at which the database application is opened to the point it is closed by the end user.
Jan 18 '14 #10

Expert Mod 15k+
P: 31,487
For me, a session is a code session.

Access can open an application window.
In the Access window you can have multiple databases open for direct interaction with the user, but only ever one at a time.
Once a database is open there is a code context, or session, that is maintained until it is stopped or reset. After that it can be restarted.

Sessions are stopped whenever code is cancelled after a bug or the Reset button (in the VBA IDE) is pressed.

I believe TempVars persist for an open database. Beyond such sessions, but not after the database is closed.
Jan 18 '14 #11

Expert Mod 5K+
P: 5,397
We may have to have some sort of new word for the tempvars object. (^_^)

I have not tried the to use these between two different frontends/databases opened thru the same instance of the Access application. I suspect though that the scope is within the frontend/database-file that created the collection.

What I do know, is that they persist within a given frontend/database until that database is closed or they are explicitly cleared; they do not clear if there is an error (unlike global variables); and they may be an option for OP to workaround the cumbersome subcontrol references within the acc2010:navigation control.
Jan 18 '14 #12

Post your reply

Sign in to post your reply or Sign up for a free account.