Default Value

  • Thread starter Thread starter Reggie
  • Start date Start date
R

Reggie

Hi and TIA! I have forms with several option groups, option buttons, list
boxes, combo boxes, etc.. Is it possible, if so how, to have the form save
the selected value of each control as the default value of that control when
the form is closed. That way when they open the form the next time, the
value they selected the last time the form was used will already be set.
Thanks for your time!

Reggie
----------
 
Reggie,

It certainly is possible! The idea is to programatically
set the value on form open... of course, you would need to
store that value somewhere so it's available when you need
it, and this would have to be a table so the data is held
ehwn the database is closed and re-opened.

What you need:

1. A table (e.g. tblLastValues) with fields fldFormName,
fldControlName, fldControlValueTXT, fldControlValueNUM,
fldControlValueDTE, fldControlValueYNO (several value
fields, depending on the data type of the controls you
want to store).

2. Code to be run by the On Close event of the form, which
first runs an SQL statement of the sort "DELETE * FROM
tblLastValues WHERE fldFormName = 'formname'", and then
opens the table as a recordset and adds new records
storing the chosen controls' values to the value fields as
dictated by each control's type.

3. Code to be run by the On Open event of the form, which
opens SQL query "SELECT * FROM tblLastValues WHERE
fldFormName = 'formname'" as a recordset, cycles through
the records and assigns values to the controls.

If this is a multi-user database, you might add an extra
field fldUserName in your table, and make the whole thing
user-specific.

HTH,
Nikos
 
Nikos, Thanks for the help. I see the light. This is a multi-user app. so
the last piece of advice is needed. Appreciate!!!!
 
Back
Top