Gasman
Enthusiastic Amateur
- Local time
- Today, 23:25
- Joined
- Sep 21, 2011
- Messages
- 16,287
Hi all,
I am just doing some reports, purely for myself with regard to the passengers I take in the Community Car.
I want to have them sorted by Surname and then Title and then Address.
So I created this small function which appears to do what I want
Having that in my query, the query responds with just a slight delay, going to the last record 1541 is almost immediate.
However having that in the source of my report and grouping by Surname, the report pretty much hangs. I see the progress bar for query about 80% full, but that is it.
Now when I had surname as just
it opened immediately?
This is the same if I add a sort in the report, previously I was just using Group By.
So what could be causing this?
It does finally open, has opened whilst I was typing this, but not really acceptable?
The reason why I created the function is that I have both a Mr & Mrs at the same address, and the Instr() version would group those as one, not separate people.
TIA
I am just doing some reports, purely for myself with regard to the passengers I take in the Community Car.
I want to have them sorted by Surname and then Title and then Address.
So I created this small function which appears to do what I want
Code:
Public Function SurnameSort(strPassenger As String) As String
Dim strTitle As String, strName As String, strAddress As String
Dim strPart() As String
Dim i As Integer
'For i = 1 To Len(strPassenger)
'Debug.Print Asc(Mid(strPassenger, i, 1)) & " " & Mid(strPassenger, i, 1)
'Next
' Need to get rid of any CHR(10) embedded from Excel
strPassenger = Replace(strPassenger, Chr(10), "")
strPart = Split(strPassenger, ",")
strTitle = Left(strPart(0), InStr(1, strPart(0), " ") - 1)
strName = Mid(strPart(0), InStr(1, strPart(0), " ") + 1)
SurnameSort = strName & "," & strTitle & "," & strPart(1)
'Debug.Print SurnameSort
End Function
Having that in my query, the query responds with just a slight delay, going to the last record 1541 is almost immediate.
Code:
SELECT GCDPivotData.Passenger, GCDPivotData.Due, GCDPivotData.Given, GCDPivotData.Tip, GCDPivotData.Percent, SurnameSort([Passenger]) AS Surname
FROM GCDPivotData
WHERE (((GCDPivotData.Passenger)<>"0")) OR (((GCDPivotData.Due)<>0));
However having that in the source of my report and grouping by Surname, the report pretty much hangs. I see the progress bar for query about 80% full, but that is it.
Now when I had surname as just
Code:
Surname: Mid([Passenger],InStr([Passenger]," "))
This is the same if I add a sort in the report, previously I was just using Group By.
So what could be causing this?
It does finally open, has opened whilst I was typing this, but not really acceptable?
The reason why I created the function is that I have both a Mr & Mrs at the same address, and the Instr() version would group those as one, not separate people.
TIA