INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Ktx7ca (IS/IT--Management) (OP)
4 Dec 08 15:04
Hello

I need to get a list box to automaticlly select the first record when it's populated.

any ideas on how to do that would be great aprecatited

Thanks Chris
PWise (Programmer)
4 Dec 08 15:17
Me.Lstbox = Me.Lstbox.Column(me.listbox.boundcolumn, 1+iif(me.listbox.columnheds=-1,1,0))
fneily (Instructor)
4 Dec 08 15:24
Or if you just used the wizard to create your listbox, on the Default property of the listbox put:
=[List0].[ItemData](0)

where List0 is the name of your listbox.
Ktx7ca (IS/IT--Management) (OP)
4 Dec 08 15:43
HI pwise  

Thanks for the info, I still have a bit of a problem, I  get the gray doted line around the first record, Instead of the black highlited line I was looking for. and of course the listbox selection value is empty.

any thoughts

thanks chris
Ktx7ca (IS/IT--Management) (OP)
4 Dec 08 15:51
HI fniely  

I'm having the same issue I had with pwise's advice. maybe I asked the wrong question as what I'm getting is that it's highlighted but not selected in my way of discribing it (or clicked if you will)

Thanks Chris

 
PWise (Programmer)
4 Dec 08 16:08
how about adding
me.listbox.setfoucs  
Ktx7ca (IS/IT--Management) (OP)
4 Dec 08 16:51
No luck there  Maybe I have it in the wrong event  
fneily (Instructor)
4 Dec 08 16:52
"it's highlighted but not selected in my way of discribing it (or clicked if you will)"

First, my highlights the first entry in the listbox.
Second, If you always want the first item "clicked", then how does the user click any of the other items? I'm assuming that On Click you're having something happen. I was going to ask if you had a multi-select listbox but that wouldn't make any sense, either. That would mean the user always wants the first item.

Maybe you could explain further.
Ktx7ca (IS/IT--Management) (OP)
4 Dec 08 17:22
Sure no problem

90% of the time the list box will only return 1 entry. and I need it to be automaticaly selected and activate the onclick event

8% of the time of the time serveral enteries will be returned but the first entry will be the correct entry. So I still want it to autoselect the first entry

For the last 2% of the time that the first entry is not what they want they will they will select the correct one from the other entries returned them selves.

does that make any sence I hope so

from working with this is I have found that after the provided code has run if I press the down arrow I get the desired result. if that helps any toward a solution

thanks chris
JBinQLD (Programmer)
5 Dec 08 9:37
G'day Chris,

If I get you right then this should sort your drama:

CODE

me.listbox.selected(0)=true

Have a great weekend

JB
ProgramError (Programmer)
6 Dec 08 10:58
You need to set the focus first before selecting the first item.
 

Ian Mayor (UK)
Program Error
9 times out of 10 I know what I'm talking about. This must be my tenth reply.
 

TheAceMan1 (Programmer)
6 Dec 08 13:55
How are ya Ktx7ca . . .

There's quite a bit of ambiguous/unclear operations going on here. surprise

You say:

Quote (Ktx7ca):

8% of the time of the time serveral enteries will be returned but the first entry will be the correct entry.
Are you saying all entries are discarded save the first? neutral This is also indicitive of a multiselect listbox, meaning what you use to run your code is outside of the listbox events!

Then you say:

Quote (Ktx7ca):

For the last 2% of the time that the first entry is not what they want they will they will select the correct one from the other entries returned them selves.
From the two quotes above there's no way to know if the first entry is required or not! I hope you can see this.

The esaiest way out here is to let the users select what they know they need and be done with it!

Quote (TheAceMan1):

If users don't know what they should select then they'll just have to learn (perhaps a quick class).

Your Thoughts . . .

See Ya! .  .  .  .  .  .

Be sure to see thread181-473997: How To Get Good Answers To Your Questions  Worthy Reading! thumbsup2
Also FAQ181-2886: How can I maximize my chances of getting an answer?  Worthy Reading! thumbsup2
                 

Ktx7ca (IS/IT--Management) (OP)
19 Jan 09 20:30
HI Sorry for the delay in getting back to you. JBinQLD your Idea works great  thanks

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close