469,125 Members | 1,640 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,125 developers. It's quick & easy.

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

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, 692 views)
Jan 15 '14 #1
11 2096
5,400 Expert Mod 4TB
1) Why?
2) show the formula/code you are using. Please format using the [Code/] button.
Jan 15 '14 #2
32,161 Expert Mod 16PB
I suspect you need to tell it to requery.
Jan 15 '14 #3
5,400 Expert Mod 4TB
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... http://bytes.com/topic/access/answer...ntrol-subforms I've made two such posts that cover the basics of using the Navigation Control.
Jan 16 '14 #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 http://bytes.com/topic/access/answer...ba#post3763553
Jan 17 '14 #5
5,400 Expert Mod 4TB
ah... something just occured to me...
the new tempvar available to ACC2010
[http://msdn.microsoft.com/en-us/libr....aspx]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: http://bytes.com/topic/access/answer...on#post3761896

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
32,161 Expert Mod 16PB
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
8,800 Expert 8TB
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
5,400 Expert Mod 4TB
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
5,400 Expert Mod 4TB
(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
32,161 Expert Mod 16PB
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
5,400 Expert Mod 4TB
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.

Similar topics

3 posts views Thread by Svennglenn | last post: by
10 posts views Thread by Shang Wenbin | last post: by
2 posts views Thread by John | last post: by
7 posts views Thread by mg | last post: by
1 post views Thread by Grey | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.