General discussion

Locked

Access Database

By ejcollins ·
How can I create a report that will sort by the first letter of a last name? For example all C's will go under the heading C.The form I have inputs the whole last name, how do I get it to look at just the first letter?Thanks

This conversation is currently closed to new comments.

6 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Access Database

by M_Ozog In reply to Access Database

This is fairly simple - hard to find in the beginning.

1) When you have your report open in design mode, selct Sorting and Grouping.

2) Select the field you want sorted by the 1st character.

3) Select the "Group On" and change it to Prefix Characters.

4) Then change Group Interval if you want more than the 1st character.

Collapse -

Access Database

by ejcollins In reply to Access Database

Poster rated this answer

Collapse -

Access Database

by Peyison In reply to Access Database

From the Sorting and Grouping option, first select the field to sort on (LastName). Then set the folowing:

Group Header = Yes
Group On = Prefix Characters

Then, in the Header for LastName, add a textbox. Set the textbox's Control Source property to:

=Left([LastName],1) (replace LastName with the actual name of your field)

Should be good to go.

Hope this helps.

Collapse -

Access Database

by ejcollins In reply to Access Database

Poster rated this answer

Collapse -

Access Database

by Bob Sellman In reply to Access Database

I'd suggest using a query as the source for the report, if you haven't already.

Add this column to the query:
FirstLetter: Left$([LastName],1,1)

(LastName should be the name of your last name column.)

I suspect that you still want your report sorted by the entire last name (and possibly also the first names). So you should set up the following sorting/grouping in your report:

FirstLetter
LastName
FirstName

Set it up so there is no header or footer for the LastName and the First Name.

Set up FirstLetter so it has at least a header. In that header you can then print the letter.

By doing the report this way you can show the letter before each set of names, but the entire list of names will be sorted alphabetically.
I think that it's a lot cleaner to use the query as the place to define the first letter of the last name, as opposed to defining an object on the report. Also makes sorting easier (and probably faster).

Collapse -

Access Database

by ejcollins In reply to Access Database

This question was closed by the author

Back to Web Development Forum
6 total posts (Page 1 of 1)  

Related Discussions

Related Forums