ComboBox won't load ItemData(0)

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
 
S

Sylvain Lafontaine

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.
 
B

Brendan Reynolds

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
 
A

aaron.kempf

jesus friggin christ; that just amazes me-- is this documented? has it
always been like this?
 
Joined
Jul 11, 2005
Messages
43
Reaction score
0
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.
 

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

Similar Threads


Top