By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,610 Members | 2,110 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,610 IT Pros & Developers. It's quick & easy.

Listbox click event

P: 42
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 .

May 19 '09 #1
Share this Question
Share on Google+
7 Replies

Expert Mod 15k+
P: 31,602
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

P: 42
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

Expert Mod 15k+
P: 31,602
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

P: 42
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

Expert Mod 15k+
P: 31,602
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

P: 42
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

Expert Mod 15k+
P: 31,602
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

Post your reply

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