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

Dynamic values for Combo Box

P: 2
I am new to Access coding , if anyone can help me it would be great


I have a patient table with fields like Firstname, lastname, DOB etc.
I have a combo box (cbName) on my form to search for a patient.
Whenever a user enters the first letter in the combo box , it should be populated with the patient names whose firstname or lastname starts with that particular letter.
And when the user enters second letter it should narrow the search and should display names according to the string entered in the combo box.

Waiting for your suggestions on this.

Thank you
Mar 25 '08 #1
Share this Question
Share on Google+
4 Replies

P: 2
Somebody Give me answer please

I am new to Access coding , if anyone can help me it would be great


I have a patient table with fields like Firstname, lastname, DOB etc.
I have a combo box (cbName) on my form to search for a patient.
Whenever a user enters the first letter in the combo box , it should be populated with the patient names whose firstname or lastname starts with that particular letter.
And when the user enters second letter it should narrow the search and should display names according to the string entered in the combo box.

Waiting for your suggestions on this.

Thank you
Mar 26 '08 #2

Expert Mod 2.5K+
P: 2,545
...I have a patient table with fields like Firstname, lastname, DOB etc.
I have a combo box (cbName) on my form to search for a patient.
Whenever a user enters the first letter in the combo box , it should be populated with the patient names whose firstname or lastname starts with that particular letter.
And when the user enters second letter it should narrow the search and should display names according to the string entered in the combo box.
...
Hi. What you describe is the default behaviour of Access combo boxes. If you use the Access wizard to create the combo the auto expand property does this for you.

Please note that your second post is not helpful, and will irritate other readers. You posted your original message yesterday, and today you nudge about receiving no response?

I believe you did not receive a reply as you have not done any research on your own for what is very simply a default behaviour of Access combos.

I would also comment that the way your question is phrased seems similar to a possible homework assignment for a School, college or university project. If this is the case please note that we cannot and will not do your homework for you.

Please read the site rules before posting in future.

MODERATOR
Mar 26 '08 #3

missinglinq
Expert 2.5K+
P: 3,532
First off, you need to learn a little patience; this forum, like most of its kind, is manned by volunteers who donate their time for free!

"Whenever a user enters the first letter in the combo box , it should be populated with the patient names whose firstname or lastname starts with that particular letter."

This is never going to happen! The AutoExpand feature of Access comoboxes only works with the bound field of the combobox. If the bound field is firstname, it will work in the manner you describe for the first name. If the bound field is lastname, it will work in the manner you describe for the last name. But a single combobox will never do this for either firstname or lastname! It's one or the other!

What you can be do is to create a calculated field that ties the firstname and lastname together and then you this combined name as your bound field in your combobox.

If you have a query based on your table, go into it in Design View. If you don't, you need to go into Design View for Queries and create a query with all the data from your table. Now go to a blank field in the query grid and type this in:

CombinedName: [LastName] & " " & [FirstName]

Now go into Design View for your form and replace the table in the RecordSource with your query. Delete your old combobox and create a new one. This time, when the Wizard comes up and asks for the table or query to retrieve the data from, select your new query. Next choose CombinedName as the field for your combobox.

That should do it.

Welcome to TheScripts!

Linq ;0)>
Mar 26 '08 #4

FishVal
Expert 2.5K+
P: 2,653
Just in addition to Linq's suggestion.

You may build a RowSource for the combo from union of queries - one concatenate first name with last name and other the same in reversed order.

Expand|Select|Wrap|Line Numbers
  1. SELECT tblNames.keyID, tblNames.txtFirstName & ' ' & tblNames.txtLastName AS txtFullName 
  2. FROM tblNames 
  3. UNION 
  4. SELECT tblNames.keyID, tblNames.txtLastName & ' ' & tblNames.txtFirstName AS txtFullName 
  5. FROM tblNames;
  6.  
Regards,
Fish
Mar 26 '08 #5

Post your reply

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