Solved

Combo Box

Posted on 2013-05-10
7
392 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 40

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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

828 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