473,748 Members | 2,685 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Listbox click event

42 New Member
Hi guys,

have a form which displays all the records i have in my database , and a search box for the user to search for a specific one .
On the search button, i run a macro which opens another form with only the records found based on the search. So far so good

On the second form, first record found is displayed ( customer and deatils)
and u can navigate through the rest . But i also have a listbox which holds only a field ( first_name ) of all the records found ,so that the user instead of going though all 50 records ,he can select one record from the listbox.

when i select a different customer from the listbox i want to fill up all the textboxes from the from with the details of the selected one .

the form is bounded to the search query , so i dont want to chage that .
any way in visual basic to fill the textboxes with the details of the selected one from the listbox ,but at the same time i want to keep the other records as well ,so i can navigate through them .

basically all i want is to jump to the selected record . if i select nothing from the listbox the form remains the same .

Thaks
May 19 '09 #1
7 4311
NeoPa
32,571 Recognized Expert Moderator MVP
@NeoPa
This is from the earlier thread.

Clearly you spent no effort whatsoever trying to explain it any more clearly. Still the same misspelled words. Still the same missed out letters from words. You haven't even bothered to try to read it back to yourself obviously.

In the circumstances I'll wait until you've posted a question that can be read clearly before pitching in with any more of my time.
May 19 '09 #2
onyris
42 New Member
Sorry about the misspelled words and missed out letters as i am not a fluent english writer.

regarding the question

all i am trying to do is :
say for example i have a list box that holds all first name fields from my table.
Based on this , on the click event of the listbox i want to build some code that will return me all the details for the selected first name.,and then to display them on the form ..

Is this make sense for you ?
i don't know how else i could explain , if you could tell me which part you don't understand and i'll try to explain again.
May 19 '09 #3
NeoPa
32,571 Recognized Expert Moderator MVP
So, if I understand you correctly, you want a ListBox control to allow the operator to select a record in the current set of data? Not to filter the existing data further, but just to take them to that record?

To facilitate this it will be necessary to know which field in the dataset can be used as a unique reference. Is it [First_Name]?

You will probably need to use :
Expand|Select|Wrap|Line Numbers
  1. Call DoCmd.FindRecord(...)
May 19 '09 #4
onyris
42 New Member
This is what i want.
About the unique reference field , i can't use the [first name] field , cose it might be more then one record with the same name.

I didn't work with listboxes and visual basic before and i don't know how to do it .
When i add the fields in the list box , i only add the [first_name] field.
Is there any way i can store the [ID] field which is the primary key along with the [first_name] so i can use that later ?
May 19 '09 #5
NeoPa
32,571 Recognized Expert Moderator MVP
You are talking about a ListBox control, but I think you may be better off working with a ComboBox control.

It is possible (in fact commonly used) to have multiple columns in these types of controls. Simply include any fields you're interested in in the SELECT clause of the query in your RowSource and adjust your ColumnCount accordingly..

To make any column invisible, set the corresponding entry in ColumnWidths to zero.

Remember, the default value of the control will match the column specified in BoundColumn.

Let us know how you get on with this.
May 20 '09 #6
onyris
42 New Member
It is working now , thanks a lot .

I forgot to change from listbox to combobox ,but still doing the job .
Thanks a lot again.
May 20 '09 #7
NeoPa
32,571 Recognized Expert Moderator MVP
If a ListBox works for you and you're happy with the way it looks then that's the business. Glad to have helped :)
May 20 '09 #8

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

Similar topics

6
7871
by: R.Wieser | last post by:
Hello All, I'm trying to get a "Virtual Listbox" to work. I've currently got a form, and used CreateWindowExA to create a ListBox with the LBS_OWNERDRAWFIXED and LBS_NODATA flags on it. I've allso subclassed the window and do see all kinds of WS_??? messages coming by. But now I'm stuck :-\ I've got *no* idea what to do next, and all my searching on the web leads me
5
3529
by: Bill | last post by:
I have have two list boxes. One is a listing of all possible variables. We'll call this listbox A. The other is a listing of all the selected variables. We'll call this listbox B. If a person double-clicks on one of the variables in listbox A it "moves" it to listbox B. What is going on behind the scenes is that the table that holds all these variables has a yes/no field call Print. When the user double clicks on the value it fires a...
8
2884
by: Oddball | last post by:
Ok - I have a ListBox control and I'm ready to write my own DrawItem event handler. What I want to draw as the item is another control. I have created a user control that I would like to list in this listbox but I can't for the life of me figure out how to draw the control inside ListBox... I get as far as: private void lbImageList_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
1
8421
by: Edward | last post by:
I am having a terrible time getting anything useful out of a listbox on my web form. I am populating it with the results from Postcode lookup software, and it is showing the results fine. What I want to do is to allow the user to click on the row that corresponds to the correct address, and have the code behind populate the form's Address1, Address2 etc. controls with the relevant data items. I put the code for this into the...
6
6183
by: Steve | last post by:
Hi, I open up a webform (vb.net) and populate a listbox control on the Page load event. If I click on (select) and item from the listbox I want to write the value of the selected item to a label control. Nothing happens. But when I click a button (which contains same code to write to label) I get the value of the selected item in the Label.
8
2356
by: Steve Schroeder | last post by:
For some reason I cannot get the OnSelectedIndexChanged event to fire for a listbox I have on a page. I'm able to populate the listbox with data from a stored procedure, but cannot trigger the event. I do have EnableViewState = True for the listbox. I'm imagining (wanting) to populate the listbox named: lstNames by using the DataValueField from lstDepartments. It's quite apparent though that the event is not triggering as I can misname...
1
1886
by: tony | last post by:
Hello! If you drag a ListBox into a windowform and then right click on this ListBox and then chose property. When you have the properties up click on the flash symbol for seeing all the events for this ListBox. The property page where you can see all the events I call property event page.
1
7064
by: superjacent | last post by:
Hope someone can point me in the right direction. When opening a form the 'click' event of the ListBox is invoked (run). I thought the 'click' event of the ListBox is only invoked when clicking it. I've looked all over the preceeding and other events on the form and definitely do not invoke the ListBox 'Click' event. What does happen during form initialisation or setup (load) is that the rowsource, columnwidths, columncount etc are...
18
4608
by: Zytan | last post by:
I want the same function to be run whether you press Enter or double click the listbox. It seems really verbose to write both handlers to both events everytime, even if they both call the same function, or one calls the other. Isn't there an event for 'ListBox selection selected' that is automatically called by ALL the standard GUI ways of doing it? C'mon, this is C#, we aren't supposed to be programming the GUI. There has to be such...
5
2854
by: Academia | last post by:
(If you've seen this in the drawing NG, sorry. I inadvertently sent it there.) I have a listbox populated with Objects. The Class has a String field that ToString returns. I assume that is what the ListBox uses for its display. Correct?
0
8995
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9561
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9381
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9332
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3316
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.