Updating RowSource comboBox property

G

Guest

Hi all,
I wrote a piece of code to update the property "RowSource" of a comboBox,
as a consequence of a "NotInList" event. The property "record source" is
"list of value".

Unfortunately, as soon as the form (where the comboBox is placed) is closed,
the value of "RowSource" is reset to the initialization value.

The question is:
Is there a way to make persistent changes made to the property "RowSource"?

The property "RowSource" is initialized with a few values and that list is
quite static in time, thus it does not deserve a DB table.

I could dinamically initialize the property "RowSource" at form load time
with the result-set of a "select distinct" but this is the last workaround
I thought.

Thanks in advance for any responses.
Roberto
 
B

Brendan Reynolds

Here's an example that I wrote in response to another question. While this
example is storing and re-assigning the Caption property of a Label control,
it can very easily be adapted to store and re-assign the ControlSource
property of a ComboBox control ...

Private Sub Form_Open(Cancel As Integer)

Dim aop As AccessObjectProperty
For Each aop In CurrentProject.AllForms(Me.Name).Properties
If aop.Name = "LastClosed" Then
Me.Label0.Caption = CStr(aop.Value)
Exit For
End If
Next aop

End Sub

Private Sub Form_Unload(Cancel As Integer)

CurrentProject.AllForms(Me.Name).Properties.Add "LastClosed", Now()

End Sub
 

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