Solved

Making all listboxes display diff. fields of the same record.

Posted on 2004-04-04
21
172 Views
Last Modified: 2011-09-20
Hi everyone at EE,

I have 3 datalist boxes. Each listbox will display a different field of the same table, each sorted alphabetically.

What I want is that when any selection is made from either of the 3 lists, the other 2 lists' corresponding record values should automatically get selected.
In this way, my adodc component is always pointing to a particular record.
0
Comment
Question by:hag1
  • 10
  • 9
  • 2
21 Comments
 
LVL 18

Accepted Solution

by:
Sethi earned 125 total points
ID: 10751749
Private Sub Listbox1_Click()
  Listbox2.ListIndex=Listbox1.ListIndex
  Listbox3.ListIndex=Listbox1.ListIndex
End Sub

Private Sub Listbox2_Click()
  Listbox1.ListIndex=Listbox2.ListIndex
  Listbox3.ListIndex=Listbox2.ListIndex
End Sub

Private Sub Listbox3_Click()
  Listbox1.ListIndex=Listbox3.ListIndex
  Listbox2.ListIndex=Listbox3.ListIndex
End Sub
0
 

Author Comment

by:hag1
ID: 10751868
I am using a datalist which has no listindex property.
So instead of listindex, which property should I use?
0
 
LVL 7

Expert Comment

by:ramesh12
ID: 10752337
C this URL
http://support.microsoft.com/?kbid=189682
and this
http://www.devx.com/vb2themax/Tip/18430
It seems there is a boundcolumn property. Just check these urls
0
 
LVL 18

Expert Comment

by:Sethi
ID: 10752733
Check the SelectedIndex property
0
 

Author Comment

by:hag1
ID: 10756221
I couldnt find any selected index property.

Anyway if you think the code in the first comment by sethi for a listbox will perform what I need, then I dont mind going for a listbox.

To connect a listbox, I tried:
datasource=adodc
datafield=column name
But, I couldnt even get the listbox to display the values.
Am I suppose to set any other property of the listbox to make it display the data?
0
 

Author Comment

by:hag1
ID: 10756243
Could anyone explain a bit in detail as to what the bound column property mean?
0
 
LVL 18

Expert Comment

by:Sethi
ID: 10756631
That was a Typing mistake...it is selecteditem property. Sorry for all the confusion.
0
 
LVL 7

Expert Comment

by:ramesh12
ID: 10757268
0
 

Author Comment

by:hag1
ID: 10758812
Sethi,

I used the selecteditem property and got the following error as soon as a selection was made in the datalist.

Run-time error 424. Object required.

During debug(when I moved my mouse over the selected statement), the LHS expression displayed 1 and RHS 2
0
 
LVL 18

Expert Comment

by:Sethi
ID: 10758913
hag1...I dont have access to VB for a few days as I am on holiday at the moment. So I am not in a position to test this at my end. Did you try the solution provided by ramesh12
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:hag1
ID: 10759026
I have viewed all the links provided by ramesh12 and I am not sure as to how exactly to use them in my case.
0
 
LVL 18

Expert Comment

by:Sethi
ID: 10759059
OK...I will go though them and tell youu in a few minutes.
0
 

Author Comment

by:hag1
ID: 10759070
ok, if I change to listbox, then what other properties apart from recordsource and datafield do I need to set?
0
 

Author Comment

by:hag1
ID: 10759091
Thanks Sethi for going through them inspite of being on a vacation.
0
 
LVL 18

Expert Comment

by:Sethi
ID: 10759223
0
 
LVL 18

Expert Comment

by:Sethi
ID: 10759232
0
 
LVL 18

Expert Comment

by:Sethi
ID: 10759240
OK, sleep time here. See ya tmr. Hope things will work out well for you
0
 

Author Comment

by:hag1
ID: 10783688
hi,
 you may take your own time to answer this question. I too was busy & couldnt reply, sorry for that.
Instead of the datalists, I simply used a databound grid.

But anyway, I would like to know how can I use datalists the way I imagined?
0
 
LVL 18

Expert Comment

by:Sethi
ID: 10783809
hag1, I wont be a great help on that becuase I dont use bound control at all.
0
 

Author Comment

by:hag1
ID: 10783960
Anyway, my aim in using 3 such lists was to make the program as user-friendly as possible. The user could have selected a particular recordset using any field he/she knew.


I think I will close the thread.

A big thanks.

hag1
0
 
LVL 18

Expert Comment

by:Sethi
ID: 10784871
Thanks for the points
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now