storing variables for later use

J

John C.

I have a form which has a combo box. Based on the user
selection, I need to store a variable for long term use.

This is a log program. As the facility changes "modes",
the needed information for turnover changes.

As the modes change, the user selects which mode it is now
in, from a combo box.

I want to recall the most recent mode that was selected,
and present a specific form that has the required info for
the related mode.

The recall could happen during the workday that it
changed, or, more likely, it will be recalled on other
days and other sessions of program use.

Q: How do I store it, and how do I recall it when needed.
 
R

Randy Wayne

There are a lot of methods Here is one that I use a lot
and it is simple.

Create a form with one unbound control. Give it a name,
like "MODE" (don't use the quotes). Give your form a
name, like frmHiddenMode.

Open the new form when you load the form you already have
(the one with the combox) as a hidden form. You can do
this by adding the following code to the Load event of
your first form.

DoCmd.OpenForm "frmName", , , , , acHidden

frmName is your Hiddn form (use the quotes this time)

so, if you used the form name I used it would be

DoCmd.OpenForm "frmHiddenMode", , , , , acHidden

Next, add the following code to the AfterUpdate event of
your combobox

Forms!frmHiddenMode.MODE = Me.yourcomboboxname

As long as the hidden form is open you can call it with

Forms!thenewform.newformname = Forms!frmHiddenMode.MODE

Also, whenever you change the combobox value, it will
store the new(est) value.

Last, close the hidden form when you are finished with it

DoCmd.Close acForm, "frmHiddenMode"

Let me know if this helps
 
J

John Spencer (MVP)

If you need to maintain the value over multiple sessions, then the best place to
store the data is probably in a field in a table.
 
J

John C.

OK...I'll set the variable in the AfterUpdate event for
the dropdown control.

Thankyou.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top