473,395 Members | 1,466 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Listbox Issue. Scroll two listboxes at same time.

Hi to all
I have two listbox with lots of items in it. I want to do is, when user scroll one listbox then second listbox automatically scroll according to first. Someone knows how to do this. I search the web but didn’t get what I really need. Help Me!
Thanx in Advance
May 11 '10 #1

✓ answered by ADezii

@SandeepJagdeva
In the absolute simplest of cases where both List Boxes contain the same number of entries, the 1st List Box is named List1, and the 2nd List Box is named List2, the following code, when placed in the AfterUpdate() Event of List 1, will keep the scrolled items of List 2 in sync with List 1 when using the UP and DOWN Arrow Keys:
Expand|Select|Wrap|Line Numbers
  1. Private Sub List1_AfterUpdate()
  2. Dim L1 As ListBox
  3. Dim L2 As ListBox
  4.  
  5. Set L1 = Me![List1]
  6. Set L2 = Me![List2]
  7.  
  8. L2.Selected(L1.ListIndex) = True
  9. End Sub
P.S. - I will not get more complicated than this since, like linq and Delerna, I would like to know also what you are trying to accomplish.

6 8182
Delerna
1,134 Expert 1GB
You need an event that occurs when the listbox scrolls.
You also need a read/write property that identifies the index of the item at the top of the list in view.
As far as I can see, in access, neither of these exist for the list box.

Maybe it's time to rethink what you are doing?
I can't imagine the scenario where you would need to do that
which wouldn't be better achieved some other way.


Microsoft does have an example of doing this
but it is done in visual basic...not VBA

google this
How to Program Two List Boxes to Scroll Together
May 11 '10 #2
missinglinq
3,532 Expert 2GB
I'd really like to know the point of this requirement. Like Delerna, I can't imagine the scenario where you would need to do that which wouldn't be better achieved some other way.

Linq ;0)>
May 12 '10 #3
ADezii
8,834 Expert 8TB
@SandeepJagdeva
In the absolute simplest of cases where both List Boxes contain the same number of entries, the 1st List Box is named List1, and the 2nd List Box is named List2, the following code, when placed in the AfterUpdate() Event of List 1, will keep the scrolled items of List 2 in sync with List 1 when using the UP and DOWN Arrow Keys:
Expand|Select|Wrap|Line Numbers
  1. Private Sub List1_AfterUpdate()
  2. Dim L1 As ListBox
  3. Dim L2 As ListBox
  4.  
  5. Set L1 = Me![List1]
  6. Set L2 = Me![List2]
  7.  
  8. L2.Selected(L1.ListIndex) = True
  9. End Sub
P.S. - I will not get more complicated than this since, like linq and Delerna, I would like to know also what you are trying to accomplish.
May 12 '10 #4
First of all Thanx to all for give me some good idias.
I gave u some detail why I need to scroll both listbox at same time. I have a form that prints Daily billing of a ‘Departmental Store’. I add two listbox name “lst_SrNo” is single column and “lstProduct_detail” with 5 column, one is for Serial No and second is for Product detail , a combobox, and some textbox for complete the task. Now user selects a product code from combobox that is connected to a table named ‘product_detail’ and detail of selected code will be loaded to lstProduct_detail, and in the lst_SrNo a number is added to it. As user select product code, then first listbox add a number like lstNumber=lstNumber+1. Product detail adds to Second listbox. Its ok till now, if user add more then 16 items in listbox then both list box need to scroll down, if user scroll “lstProduct_detail” listbox then its corresponding Serial No. does’t match. is it clear

Why I need two list box?
Ans is in my previous post :
http://bytes.com/topic/access/answer...-listbox-value
May 12 '10 #5
@ADezii
Thanx man
This is what i need. This will sloved my problem, is any way, that this will wrok with mouse as with key up-down, when user click on scroll button of listbox?
May 12 '10 #6
ADezii
8,834 Expert 8TB
@SandeepJagdeva
To the best of my knowledge, this simply cannot be done.
May 12 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Kelly Vernon | last post by:
I have a standard ASP page that appends to an xml page. Currently if there is more than one person attempting to append to the same XML file at a time. One user will have the ability to append,...
3
by: intl04 | last post by:
I was told by an instructor of Oracle SQL that an MS Access database cannot be used to have several people enter records at about the same time, that the database will "freeze up" as a result -...
1
by: Peter | last post by:
Hello, Thanks for reviewing my question. My SQL table has a few string columns and a image column. After inserting a new row into the dataset with the columns populated, I tried calling the...
5
by: Jeremy | last post by:
I have a core VB service that monitors a database, and based on data in the records will execute code to send email notifications. Problem: I don't want my main program code to halt and wait for...
2
by: Amrit | last post by:
Hi Can anyone help me? I would really appreciate I am trying to scroll Groupboxes inside the panel when i hold panel's scroll bar and drag up and down. Such as Internet explorer where you can hold...
1
by: Chris | last post by:
Why does the listbox pause during the first time it has to scroll but moves fluidly ever time after that? Chris
2
by: elaine | last post by:
I'm working on a .net web application. The architect of this web application is quite different than other web applications i worked before. Since we use a set of tools to generate most of the...
5
by: Cichy | last post by:
Hello, I'm writing a Client-Server application using sockets (asynchronous). There is a Server (Master) which accepts incoming connections, and Client (Slave). Afetr establishing connections...
2
by: chrisf01 | last post by:
I am trying to write to a text file and the database at the same time. I have a For statement that loops through all the repeated fields in my form and writes it to a text file. That part works 100%...
4
by: simion314 | last post by:
Hi, i need to use a owner draw listbox(i am using windows forms in NET 2.0 ). I created a testlistbox ,implemented the DrawItem method and it works fine, it scrolls with the mouse wheel. After that i...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.