[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Set TempVar value based on a combo box?

Posted on 2010-11-29
7
Medium Priority
?
2,097 Views
Last Modified: 2013-11-27

I need the following sequence to happen:

1. User selects a YEAR from a combo box [cmbo_Year]
2. They open another form (original form closes) and do some stuff
3. They return to the original screen in step 1.
4. I want [cmbo_Year] to show the value that they had selected previously in step 1.

I can't quite seem to figure out how TempVars work (I'm assuming that they are the solution to this problem).

This database is independent, and is NOT used by multiple users.  It is specific for ONE user at a time, so there will be no issues with someone being in there at the same time, and changing the Year combo box value.
Thanks for any help.
0
Comment
Question by:SheaJeff
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 2

Assisted Solution

by:compTrack
compTrack earned 800 total points
ID: 34232450
Hello There !!

What you need to do is store the value selected in step 1 in a global variable. Let the user do whatever he/she wants to do in step 2.

In step 3 when they return to the original form, you need to obtain the value back from the global variable and display it in whatever way it is that you want.

Alternatively, you can try and store the selected year in Step 1 in a table. And when the user returns back to the form (in step 3) retrieve that value back from the table and display it.

Best Of Luck

compTrack
0
 
LVL 7

Accepted Solution

by:
RemRemRem earned 1200 total points
ID: 34232459
One of the quickest "cheats" to handle this is to simply make the original form invisible, instead of closing it. Then the value hasn't been wiped when the recordset closes because, well, it never does!

Otherwise, you need to create a global variable (Public gintYear as integer, say) and store the cmbo_Year value in that global variable as you close the form (On Close, gintYear = me.cmbo_Year) until you re-open the form, and then, upon opening it, set the cmbo_Year = gintYear

-Rachel
0
 

Author Comment

by:SheaJeff
ID: 34232820
I'm going to accept both of your solutions for the global variable, but have another add-on to this question:

How can I get the [cmbo_Year] default value set back to "current year" when the database is closed?
That way it the form always originally comes up showing the current year.
0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
LVL 7

Expert Comment

by:RemRemRem
ID: 34232886
I think what you're actually asking is how do you default it upon opening, in which case you can set the combo box's default value to:

 =year(date())

-Rachel
0
 

Author Comment

by:SheaJeff
ID: 34232918
I already have the =year(date()) as the default value.
But once the global variable is set, it seems to over ride the default value...
0
 
LVL 7

Assisted Solution

by:RemRemRem
RemRemRem earned 1200 total points
ID: 34232950
If this is happening after you've closed and reopened the database, then you've got some code assigning values to the global variable in the wrong place - it may be that you're setting the global variable too soon?

-Rachel
0
 

Author Comment

by:SheaJeff
ID: 34233174
I found the problem;
I was setting the value of cmbo_Year on the Form_Open event.  
When the database started up, it would give me a zero until I selected something, then everything worked fine.
I had to add this to the Form_Open assignment for the cmbo_Year:

If gintYear <> 0 then
   cmbo_Year.value = gintYear
Endif
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question