Stephan888
Programmer
To all Crystal experts,
We've built a VB6 app which allows the user to control parameter entry, selection, grouping and sorting criteria for .rpt files from a flexible and powerful GUI.
Everything's working beautifully except for one thing: grouping on a datetime field causes an "invalid group condition" error with the GroupCondition property, and I'm pulling my hair out (what's left of it, that is) trying to solve this.
I did find this article -- -- on the Crystal KB website. It says to use the crGCDaily value instead of crGCAnyValue for date fields. Okay, so this is what I did in my VB grouping code:
'*** BEGIN CODE SNIPPET ***
With g_CRXrpt
'... more code here ...
'*** GROUP FIELD
'(Note: For our reports, grouping is based on formula fields
'like Group1, Group2, etc. instead of database fields.)
'Change grouping formula here to appropriate {table.field}
'value.
.FormulaFields.GetItemByName("Group" & CStr(m)).Text = _
"CStr({" & strRptTblName & "." & strFieldNameNoAlias & "})"
'*** GROUP CONDITION
'If field type is date use crCGDaily, otherwise use
'crGCAnyValue.
'*** ERROR always happen here with date-type field
'*** even when setting GroupCondition to crGCDaily!
If strFieldType <> "Date" Then
.Areas("GH" & CStr(m)).GroupCondition = crGCAnyValue
Else
.Areas("GH" & CStr(m)).GroupCondition = crGCDaily
End If
'*** GROUP SORT DIRECTION
If UCase(cboGroupDirection(n - 1)) = "ASC" Then
.Areas("GH" & CStr(m)).SortDirection = crAscendingOrder
Else
.Areas("GH" & CStr(m)).SortDirection = crDescendingOrder
End If
'... more code here ...
End With
'*** END CODE SNIPPET ***
In any event, I'm at my wits end. I can't tell what else I'm doing wrong and I can't find any more information on this error on the Crystal site or anywhere else. If any of you Crystal experts have experienced this error with the GroupCondition or can shed some light on the matter, I'd greatly appreciate it.
Thanks in advance,
--Stephan
We've built a VB6 app which allows the user to control parameter entry, selection, grouping and sorting criteria for .rpt files from a flexible and powerful GUI.
Everything's working beautifully except for one thing: grouping on a datetime field causes an "invalid group condition" error with the GroupCondition property, and I'm pulling my hair out (what's left of it, that is) trying to solve this.
I did find this article -- -- on the Crystal KB website. It says to use the crGCDaily value instead of crGCAnyValue for date fields. Okay, so this is what I did in my VB grouping code:
'*** BEGIN CODE SNIPPET ***
With g_CRXrpt
'... more code here ...
'*** GROUP FIELD
'(Note: For our reports, grouping is based on formula fields
'like Group1, Group2, etc. instead of database fields.)
'Change grouping formula here to appropriate {table.field}
'value.
.FormulaFields.GetItemByName("Group" & CStr(m)).Text = _
"CStr({" & strRptTblName & "." & strFieldNameNoAlias & "})"
'*** GROUP CONDITION
'If field type is date use crCGDaily, otherwise use
'crGCAnyValue.
'*** ERROR always happen here with date-type field
'*** even when setting GroupCondition to crGCDaily!
If strFieldType <> "Date" Then
.Areas("GH" & CStr(m)).GroupCondition = crGCAnyValue
Else
.Areas("GH" & CStr(m)).GroupCondition = crGCDaily
End If
'*** GROUP SORT DIRECTION
If UCase(cboGroupDirection(n - 1)) = "ASC" Then
.Areas("GH" & CStr(m)).SortDirection = crAscendingOrder
Else
.Areas("GH" & CStr(m)).SortDirection = crDescendingOrder
End If
'... more code here ...
End With
'*** END CODE SNIPPET ***
In any event, I'm at my wits end. I can't tell what else I'm doing wrong and I can't find any more information on this error on the Crystal site or anywhere else. If any of you Crystal experts have experienced this error with the GroupCondition or can shed some light on the matter, I'd greatly appreciate it.
Thanks in advance,
--Stephan