Beginning Access 2003 VBA

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

Anybody read this book by Denise Gosnell. I like the direction but I'm
running into problems populating a combo box and then setting a selection by
value and not by numbered list - 0, 1, 2, 3, etc. This is all unbound,
hand-coded stuff. Basically I need to select an item in the combo box like
this:

cboPlans.SelectedValue = ParentTablePlanId

Here's what's happening right now:

If item 0 has a PlanId=0, great.
If item 1 has a PlanId=1, great.
If item 2 has a PlanId=39, not good because there are only 3 items in the
list - 0, 1 ,2.

Do I need to write my own method (routine) for this? FYI, I've been
spending a lot of time with VB.NET and just kind of checking out Access 2003
right now.

Thanks,
Bill
 
Hi,
dont know about this book, and code, but it looks like you should pass index
to SelectedValue, not actual value. index - is a position in list items
collection when you fill combo.
 
You don't mention how you filled the combo box in the first place?

Also, is this combo box a multi-column combo...or just ONE column?

The ms-access combo box is more then 10 years old, but in fact STILL REMAINS
likely the best combo box in terms of simplicity, and also in terms of
features (you got great features like a not in list event that you don't
have in vb).

Further, you can supply the combo box with a string delimited "value list",
or simply supply the combo with a sql string. (no connection object, no
mess, just go:

strSql = "select id, Customer from tblCustomers where ActiveCust = True"

me.cboCombo1.RowSouce = strSql

(gee, only two lines of code to load up a whole combo box!! (how much work
and hoops do you go through to do that in .net???).


So, the first thing here to expand on is how did you fill the combo? If you
are just trying to make a "value list", then use the wizard to make the
combo for you...

Just shove your value right into the combo like:

cboPlans = PartnetTablePlanID

Also, you are using ?:

cboPlans.SelectedValue = ParentTablePlanId

A combo box does not have a SelectedValue property, so can I assume this is
typo in your post?
 
Back
Top