combobox default itemdata value

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

Guest

Hello,
I have an access 2000 form with comboboxes, that are bound to a
query that populates them with "Project names" from the table. The problem I
have is that we want to make the default item that shows in the combobox as
soon as the form is loaded as "-select project-"( to let the user know what
the function is"). Since it is bound to a query I have added that as a dummy
record in the table and pull it up by itemdata(index).. but I was wondering
if there was another efficient way to do it, since I don't like adding dummy
records to the table. I also tried to add it as cbo.itemdata(0) as in vb but
vba does not give me that option.

thanks
MC
 
MC,
Since "-select project-" is in the list (via your dummmy entry), you
could just use the DefaultValue for the combo. In the future, your .index
may change, and all you really need "-select project-" displayed for is
"New" records.

But... I really have to question using the bound control "displayed"
default value as a descriptive "pseudo-label". That's what labels are for.
Your combo should have it's own label like "Select Project:", and none of
these further machinations would be necessary. Displaying descriptive
text "in" bound controls can be very confusing to users, and adding a dummy
entry to a legitimate list of values, to work around the inherent problems
this creates, should tip you off that this method is not really the right
way to go.

hth
Al Camp
 
You can use a union query instead of adding the 'dummy' value to the table
....

SELECT "-select project-" FROM tblProjects
UNION SELECT ProjectName FROM tblProjects

I know this looks a little odd, as "-select project-" does not exist in the
table, but each SELECT in a Jet union query must have a FROM, and this
works.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Back
Top