Combo Box selecting first item in list

G

Guest

I am trying to make 3 combo boxes display the first items in their lists when
the form opens but access is giving me error 2448 "You can't assign a value
to this object".

Below is the code I am trying to use. Can anybody tell me what could be
wrong with this OR provide a code that will work. Basically, I want the
combos to display a value when the form opens up.

Pele



Private Sub Form_Open(Cancel As Integer)
Me.[CboJobTitle].Value = Me.[CboJobTitle].ItemData(1)
Me.[CboSchedule].Value = Me.[CboSchedule].ItemData(1)
Me.[cboShift].Value = Me.[cboShift].ItemData(1)
end sub
 
G

Guest

Check the fields you are trying to assign a value to, probably one of them is
bounded to a field you can't update, for example a field that is bounded to a
calculation formula like (iif, Sum, = to something, etc)
 
G

Guest

First, Itemdata is 0 based, so replace the (1) with (0),
Second, Move the code for each combo box to its Default Value property:
= Me.CboJobTitle.ItemData(0)
 
B

Bas Cost Budde

Private Sub Form_Open(Cancel As Integer)
Me.[CboJobTitle].Value = Me.[CboJobTitle].ItemData(1)

I think that should read

cboJobTitle = cbojobtitle.itemdata(0)

(1) refer to the control, which is not a property or member of Me
(2) omit Value as that is the default property of a control
(3) as Klatuu mentions, the first item has index number 0
 

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