need coding for unique default value issue...

  • Thread starter Thread starter Lynniebird
  • Start date Start date
L

Lynniebird

I have a drop-down list in a form that the end-user selects a number from.
Once this number is selected, I need the selection to remain on that number
throughout the entry of various records. I want that number to be placed in
the default value of the properties form and that number to remain the same
until it is changed by a different user--even after the form is closed and
reopened. Is this possible?
 
To store the number from one record to the next is easy enough... make a
variable in the top of the form's module to hold the value, then in the
Current event set that value to the combobox value.

Ex:

Option Compare Database
Option Explicit

Private piComboDefault as Integer

Private Sub Form_Current()
Me.Comboboxname = piComboDefualt
End Sub

Private Sub ComboName_AfterUpdate
piComboDefault = Me.Comboname
End Sub


For closing and reopening the form, you could do a few things. Either save
the value to a table, and read it back on the form open, or, use a static
variable (static variables do not lose their value unless the application is
exited).

Dim a static variable like so:

Private Sub Form_Current()
Static siComboDefault As Integer
...
...
End Sub


it will take a little bit of playing around to set and read the static
correctly, but these types of variables are designed to do as you seek.


Also, if you are in A2007, you have the option of using TempVars. I don't
know the details, but you can google it to get some info, it doesn't seem
that difficult (though I don't use 07 myself).


hth

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
Jack,

I am very new at this, so please bear with me. I need more specifications
on what coding goes where.
 
Back
Top