How do I set a default value for a combo box when closing a form?

WindSailor

Registered User.
Local time
Yesterday, 18:15
Joined
Oct 29, 2003
Messages
239
How do I set a default value for a combo box when closing a form?
I have several filtered combo boxes that work in succession just fine, but I like the idea of changing the default value of those combo boxes to the last value entered so when that individual wouldn't have to go through the sequence again when opening the form.
I have tried:

Me.cb1.SetFocus
Me.cb1.DefaultValue = Me.cb1.Value

with no success...

Is there a way to do this without storing a value?

Thanks
 
Wind,

Technically, your combo doesn't store a value. If you wanted to save it,
you could possibly:

1) Open the form in design view
2) Set its current value as the default value
3) Save the form

Other than that, you will have to store its value (and any others) in a table.

Wayne
 
Your right... I went back and checked the MSDN site... which said...

Note The Value property is not the same as the DefaultValue property, which specifies the value that a property is assigned when a new record is created.

In essence... I am not creating a new record... I should be assigning a value...
 
Last edited:
I found a way to assign the values to the filtered combo boxes on the form (which in this case has to be a pop-up form) without saving to a table, providing that the main form is or remains open, other wise you will have to go through the sequence or save the values to a table.

Code:
Private Sub Form_Load()

If CurrentProject.AllForms(Form1) _
    .IsLoaded = True Then

Me.cbo1.Value = Forms![Form1]!Text1
Me.cbo2.Value = Forms![Form1]!Text2
Me.cbo3.Value = Forms![Form1]!Text3

    Else
        DoCmd.OpenForm "Form2", acNormal
End If

End Sub

This was all I needed for now...
 

Users who are viewing this thread

Back
Top Bottom