Solved

Combo Box

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

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.

Join & Write a Comment

Suggested Solutions

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

708 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

15 Experts available now in Live!

Get 1:1 Help Now