Setting Initial Values In A Combo Box 
Author Message
 Setting Initial Values In A Combo Box

I am currently using a combo box in a form to select records displayed in a
subform.
i.e to display all records for a particular company

The combo box is populated with values from the companies table

On opening the form there is no value shown in the combo box.

I would like to be able to do both of the following:

1. Have the first value in the list displayed in the box; or

2. Specify the list item (ie ComNum5) and have it displayed in the box on
opening the form

Any thoughts for a good solution?

Guy



Sat, 12 Aug 2000 03:00:00 GMT  
 Setting Initial Values In A Combo Box

Guy,

I take it that your combo box is not bound and that you are using it to
control as sort of a filter control for already existing records.  What you
need to do is set the default value property of the combo box to the value
that you would like.  Then you will have call the function or sub that you
are using to sync your subform on the onload event of your form.  That
should do it.  I hope it helps.

If you want to do it all using code then try this in your form class module

Sample Code

Private Sub Form_Load()

    Me.cboCompanyName = "Your Company"

    If Not FuncSyncSubform Then
           MsgBox "Unable to sysnc the sub form", vbInformation
    End If

End Sub

Private Function FunSyncSubform() as Boolean

        Your sync code That returns true if successful sync and false if
not.

Exit Function

Alan

Quote:

>I am currently using a combo box in a form to select records displayed in a
>subform.
>i.e to display all records for a particular company

>The combo box is populated with values from the companies table

>On opening the form there is no value shown in the combo box.

>I would like to be able to do both of the following:

>1. Have the first value in the list displayed in the box; or

>2. Specify the list item (ie ComNum5) and have it displayed in the box on
>opening the form

>Any thoughts for a good solution?

>Guy




Sun, 13 Aug 2000 03:00:00 GMT  
 Setting Initial Values In A Combo Box

Quote:
>I would like to be able to do both of the following:

>1. Have the first value in the list displayed in the box; or

Set the combo's default value property in design time to:

=cboTheCombo.itemdata(0)

Quote:

>2. Specify the list item (ie ComNum5) and have it displayed in the box on
>opening the form

Do the same thing, only specify a different itemdata(x) value.

-- Jim Ferguson, FMS
   http://www.fmsinc.com



Sun, 13 Aug 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Setting Initial Value In Combo Box

2. How to set default value of combo box to value of record in database

3. enter data in a combo box based on value from another combo box

4. Setting Combo box ListIndex initiates Combo box Click event

5. For a bind combo box with display member and value member set

6. setting a default value to a Combo box

7. Setting value in combo box

8. Combo box - initial display

9. How do you set the initial value of a Static variable

10. Combo date value set by code gets ignored by combo's list when opened

11. Rich Text Box Problems Setting initial font

12. Putting a value from a combo box into a text box on a form

 

 
Powered by phpBB® Forum Software