Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

!!!Dynamic dropdown parameter lists 3

Status
Not open for further replies.

yuli1104

Programmer
Feb 20, 2002
60
CA
Hello friends,
Maybe my last posting confused people. hope this one can clear the question up.
I would like to have the listed value of the parameter in my report dynamically change as the data changes occasionally. Currently I have to go in and manually make it update and then save the report again each time the data changes. Is there any easy way to get these to change dynamically? Thanks!
 
Sorry, there isn't really - although this is a common request.

The only real way to do this is to write the drop-down in VB (in an application form) and then pass the selected values to CR. Stand-alone CR can't do this. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
I have heard this idea described, but I haven't tested it. My gut tells me that the AddDefaultValue command would add values for runtie, but that they wouldn't get saved with the RPT if the app saved the report. I could easily be wrong on this, but I assume that you will know the answer shortly and that you will let us know.

Not exactly dynamic, but better than manually modifying the report. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Like Ken said this is not easy but it can probably be done.
see faq149-1485 for some ideas on this. Software Support for Macola, Crystal Reports and Goldmine
dgilsdorf@mchsi.com
 
Yes it is possible to do for I have done it. Through VB you can save the report and the new PickList values. Here is a sample code snippet:


Do While f.atendofstream <> True
ParamLine = f.readline
Call ParseDelimitedString(ParamLine, TokenList, vbTab)

For j = 1 To CrRep.ParameterFields.Count

If CrRep.ParameterFields(j).Name = &quot;{?&quot; & TokenList(1) & &quot;}&quot; Then

Do Until CrRep.ParameterFields(j).NumberOfDefaultValues = 0
CrRep.ParameterFields(j).DeleteNthDefaultValue (1)
Loop
'Delete all the original parameter values from the parameter picklist.
'If you want to keep the orginal parameter values in the parameter picklist, comment out this loop.

If TokenList(0) = 0 Then
CrRep.ParameterFields(j).AddDefaultValue TokenList(2)
CrRep.ParameterFields(j).DisallowEditing = True
Else
If UBound(TokenList) = 3 Then
' we are including an All provision
CrRep.ParameterFields(j).AddDefaultValue &quot;&quot;
CrRep.ParameterFields(j).NthValueDescription(1) = TokenList(3)
End If

If ParamRs.State = adStateClosed Then
Call ParamRs.Open(TokenList(2), cnn1, adOpenDynamic, adLockReadOnly)
'Create an ADO recordset that selects all fields from the Query.
End If

ParamRs.MoveFirst
'Move to the first record so you don't miss any records in the loop

Do Until ParamRs.EOF = True
'Only loop until the end of the recordset

CrRep.ParameterFields(j).AddDefaultValue ParamRs.Fields(0).Value
ParamRs.MoveNext
'Move to the Next Record in our field
Loop


If ParamRs.State = adStateOpened Then
ParamRs.Close
End If

End If

End If
Next

Loop

f.Close ' close the list file


CrRep.SaveAs ReportName, cr80FileFormat
'Save an updated copy of your report file. This new report contains the parameter picklist

Set CrRep = Nothing
 
Very cool. Thanks Scarmody.
Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Thanks, Scarmody!!! That's just what I needed to read.

Any idea if this can be done from within CE, rather than using VB?

I was hoping to not use VB, and to customize CE to allow the users to decide if a report is automatically updated, perhaps even at the parameter level, but just being able to do so for all parameters is very helpful.

-k kai@informeddatadecisions.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top