Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Combo Box

Posted on 2013-05-10
7
Medium Priority
?
399 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 2000 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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 

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 2000 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

885 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