ComboBox won't load ItemData(0)

  • Thread starter Thread starter Wes Peters
  • Start date Start date
W

Wes Peters

I have a combo box with a stored procedure as a row source and I want the
first item in the list to appear instead of it being blank. I used the
ComboBox = Combox.ItemData(0) and it worked until I made a change to the sp.

I adjusted settings on the combo box to be 3 columns instead of two and
added column headers.

Any thoughts?
Thanks,
Wes

The sp is:

Alter Procedure spGetPlansActive
@CustID int

As

SELECT tblPlans.PlanID,tblPlans.PlanName,tblPlans.ReceiptDate

FROM tblPlans

WHERE (@CustID = CustID) And (tblPlans.Inactive = 0)

ORDER BY tblPlans.PlanName
 
Refresh the Views/Stored Procedures/Functions window with F5 or View ->
Refresh.

If this doesn't work (it should), then try remplacing ItemData(0) with
Column(0,0). Recompiling all modules can also be of some help.
 
It's the column headers - when you add them, they become ItemData(0), and
the first row of data becomes ItemData(1).

You could change the code to point to ItemData(1) instead of ItemData(0), or
use something like this, so that it will keep working even if you decide to
hide the column headers again ...

Private Sub Form_Load()

If Me.Combo0.ColumnHeads Then
Me.Combo0 = Me.Combo0.ItemData(1)
Else
Me.Combo0 = Me.Combo0.ItemData(0)
End If

End Sub
 
jesus friggin christ; that just amazes me-- is this documented? has it
always been like this?
 
I am not sure if this is related to your problem but…

Did you know that if a parameter name in you stored procedure matches a field name on you form. The combo box will attempt to use that field name as the parameter for the SP.

This is great for making combo box populate other boxes; however is barley mentioned in access help.
 
Back
Top