Solved

Combo Box

Posted on 2013-05-10
7
389 Views
Last Modified: 2013-05-11
I have a combo box  with the follow:

SELECT Strings.Claimant
FROM Strings
GROUP BY Strings.Claimant
ORDER BY Strings.Claimant;

The problem is we want to the select the Claimant but their last name , however Claimant is a single column with firstname and last name.  I would rather not have to change the tables design to have the first name and last name seperate, is there a way to do this?
0
Comment
Question by:seamus9909
  • 4
  • 2
7 Comments
 
LVL 61

Assisted Solution

by:mbizup
mbizup earned 500 total points
ID: 39155794
Change your ORDER BY:


SELECT Strings.Claimant, Mid(Claimant, instr(1, Claimant," ") + 1)
FROM Strings
GROUP BY Strings.Claimant
ORDER BY Mid(Claimant, instr(1, Claimant," ") + 1)

Open in new window

0
 
LVL 39

Expert Comment

by:als315
ID: 39155826
Generally you can't do it, because first and last name can have more then one word. How can you do it with names like:
Wernher Magnus Maximilian von Braun
John Fitzgerald Kennedy
Jacqueline Kennedy Onassis
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39155850
seamus9909,

My suggestion is of course assuming very well behaved data in the form "First Last"  without secondary "words" in either part of the name.

IF your data contains exceptions to this rule, then you really should redesign your table (which is the all-around 'best solution' anyhow).
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

Author Comment

by:seamus9909
ID: 39155908
The data doesnt contain an exceptions.   When i try to run that SQL I receive a data mismatch error??
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39155932
Do you have any blank/null or one-name clamaints (no last name)?


Try this:

SELECT Strings.Claimant, Mid(Claimant, instr(1, Claimant," ") + 1)
FROM Strings
WHERE Claimant & "" <> ""
GROUP BY Strings.Claimant
ORDER BY Mid(Claimant, instr(1, Claimant," ") + 1)

Open in new window

0
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 39155945
Also, unless you have fields which you have not shown here, your GROUP BY is not needed:


SELECT Strings.Claimant, Mid(Claimant, instr(1, Claimant," ") + 1)
FROM Strings
WHERE Claimant & "" <> ""
ORDER BY Mid(Claimant, instr(1, Claimant," ") + 1)

Open in new window

0
 

Author Comment

by:seamus9909
ID: 39156051
so that works.  So that combo box (combo171) is used as the Master for a subform.

The subform uses the Master Field as combo171
and the child as "claimant".  That way if you select in combo box a name that has multiple records for the Claimant they will display in the subform.

So im thinking I have to change the Parent and Child relationship in the form correct?

Like    Master is  combo171.column(2)
 since the claimant is in COlumn2 of the SQl for the Combobox?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

948 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now