Solved

Set TempVar value based on a combo box?

Posted on 2010-11-29
7
2,027 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 200 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 300 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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 300 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

726 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