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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|