A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Name searching problem



 
 
Thread Tools Display Modes
  #1  
Old May 28th, 2010, 12:17 AM posted to microsoft.public.access
David G.[_3_]
external usenet poster
 
Posts: 60
Default Name searching problem

I have an interesting request from a user, but I don't see how to
implement the request.
When populating a combox with employee names, the user wants to see
first & last names which match any text being typed in.
Example, if the user types in "LA", the drop down box would include:
"Larry Johnson"
"Larimy Smith"
"Lansdown, Phil"
"Lany, Tom"

I feel like I will need to create a table with 2 entries for each
name. The first entry would be [First] & " " & [Last], and the second
entry [Last] & ", " & [First]. The problem is keeping the table
current with any name changes without rebuilding the table every time
there is a name change.

Any thoughts would be greatly appreciated.
THANKS!
David G.
  #2  
Old May 28th, 2010, 02:07 AM posted to microsoft.public.access
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Name searching problem

On Thu, 27 May 2010 19:17:42 -0400, David G. wrote:

I have an interesting request from a user, but I don't see how to
implement the request.
When populating a combox with employee names, the user wants to see
first & last names which match any text being typed in.
Example, if the user types in "LA", the drop down box would include:
"Larry Johnson"
"Larimy Smith"
"Lansdown, Phil"
"Lany, Tom"

I feel like I will need to create a table with 2 entries for each
name. The first entry would be [First] & " " & [Last], and the second
entry [Last] & ", " & [First]. The problem is keeping the table
current with any name changes without rebuilding the table every time
there is a name change.


You're missing the most powerful feature of Access: Queries.

You certainly do NOT need to, nor should you, have the full name stored in any
table, in either format!

Your employee table should have fields such as EmployeeID (a unique, stable,
primary key), LastName, and FirstName.

You can base two combo boxes on two queries based on this table, using your
expressions as calculated fields in the query, and the EmployeeID as the bound
column. These queries will dynamically retrieve whatever names are currently
in the table - that's what queries are *for*. Nothing is needed to "keep the
table current" or "rebuild".

You could even include every name in the combo's rowsource twice, once each
way, using a UNION query. Given the above table design, you can go to the SQL
window of a new query and edit it to

SELECT EmployeeID, [LastName] & ", " & [Firstname] FROM Employees
UNION ALL
SELECT EmployeeID, [FIrstName] & " " & [Lastname] FROM Employees
ORDER BY 2;

The 2 means to order by the second field (the full name). Use this query as
the combo's rowsource.

--

John W. Vinson [MVP]
  #3  
Old May 28th, 2010, 01:36 PM posted to microsoft.public.access
David G.[_3_]
external usenet poster
 
Posts: 60
Default Name searching problem

Thanks! Works perfect.

On Thu, 27 May 2010 19:07:02 -0600, John W. Vinson
wrote:

You're missing the most powerful feature of Access: Queries.

You certainly do NOT need to, nor should you, have the full name stored in any
table, in either format!

Your employee table should have fields such as EmployeeID (a unique, stable,
primary key), LastName, and FirstName.

You can base two combo boxes on two queries based on this table, using your
expressions as calculated fields in the query, and the EmployeeID as the bound
column. These queries will dynamically retrieve whatever names are currently
in the table - that's what queries are *for*. Nothing is needed to "keep the
table current" or "rebuild".

You could even include every name in the combo's rowsource twice, once each
way, using a UNION query. Given the above table design, you can go to the SQL
window of a new query and edit it to

SELECT EmployeeID, [LastName] & ", " & [Firstname] FROM Employees
UNION ALL
SELECT EmployeeID, [FIrstName] & " " & [Lastname] FROM Employees
ORDER BY 2;

The 2 means to order by the second field (the full name). Use this query as
the combo's rowsource.

THANKS!
David G.
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:19 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.