Link to home
Create AccountLog in
Crystal Reports

Crystal Reports

--

Questions

--

Followers

Top Experts

Avatar of leechoonhwee
leechoonhwee

This value is write-only
Hi all

Was trying to pass some parameters from VB to CR9 when the above error was encountered. This is the line that hits it.

crRpt.ParameterFields.GetItemByName("iInvno").AddCurrentValue invoiceno

I am very new to CR so any help apprciated.

Thanks

Zero AI Policy

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


Avatar of GJParkerGJParker🇬🇧

This line looks fine could you post the rest of your code

Avatar of leechoonhweeleechoonhwee

ASKER

Dim crApp As CRAXDRT.Application
Dim crRpt As CRAXDRT.Report

invoiceno = 2062

Set crApp = New CRAXDRT.Application

    Set crRpt = crApp.OpenReport(App.Path & "\invoice.rpt", 1)
    crRpt.Database.LogOnServer "P2sodbc.DLL", "xxx", "xxxx", "xxxxx", "xxxxxx
   
    crRpt.RecordSelectionFormula = "{HomedInvoice.iInvno} = '" & invoiceno & "'"
    crRpt.ParameterFields.GetItemByName("iInvno").AddCurrentValue invoiceno
   

    crRpt.MorePrintEngineErrorMessages = False
    crRpt.EnableParameterPrompting = False
    crRpt.DiscardSavedData
   
    Me.rptCRViewer.ReportSource = crRpt
    Me.rptCRViewer.ViewReport
    Me.Show

ASKER CERTIFIED SOLUTION
Avatar of Mike McCrackenMike McCracken

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Create Account

ohhh.. I think I may have given the wrong idea. What I am trying to achieve is to pass a value to the parameter "iInvno". I do not know whether my coding is correct at all in the first place.

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


I understood what you are trying.  Try my code to see if it works.  I only have CR8 and no references for CR9 so I don't know if the properties/methods you are using exist.  I know they don't in CR8.

mlmcc

Hmmm...I only have 1 parameter on the report and based on the code given by you I should do something like:

crRpt.ParameterFields(0).AddCurrentValue invoiceno

but that also give me the same error message. Strange.....

SOLUTION
Avatar of frodomanfrodoman🇺🇸

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.

You are correct frodoman.  Though there are some things in Crystal indexed from 0.

mlmcc

Free T-shirt

Get a FREE t-shirt when you ask your first question.

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


Hi all

Changed the code but the error is still there....any other possibilities?

Is there a way to pass the value to the parameter using name instead of index?

Avatar of frodomanfrodoman🇺🇸

Can you show your code as it is now after the above changes?

frodoman

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


Is there a way to pass the value to the parameter using name instead of index?
I don't think there is with the RDC.  It could be done with other methods but I believe I read that Crystal removed that feature.

mlmcc

Ok, now I dun encounter any error but the parameter is not shown on the report. This is revised code.

Dim crApp As CRAXDRT.Application
Dim crRpt As CRAXDRT.Report

invoiceno = "2062"

Set crApp = New CRAXDRT.Application

    Set crRpt = crApp.OpenReport(App.Path & "\invoice.rpt", 1)
    crRpt.Database.LogOnServer "P2sodbc.DLL", "xxx", "xxxx", "xxxxx", "xxxxxx
   
    crRpt.RecordSelectionFormula = "{HomedInvoice.iInvno} = '" & invoiceno & "'"
    crRpt.ParameterFields(1).AddCurrentValue invoiceno
   

    crRpt.MorePrintEngineErrorMessages = False
    crRpt.EnableParameterPrompting = False
    crRpt.DiscardSavedData
   
    Me.rptCRViewer.ReportSource = crRpt
    Me.rptCRViewer.ViewReport
    Me.Show

On running a param compare shown below, there is actually something passed to the parameter but it is not showing on the report. However there is no error reported.

Dim cParam As CRAXDRT.ParameterFieldDefinition
For Each cParam In crRpt.ParameterFields
    Debug.Print cParam.Name
    Debug.Print cParam.IsCurrentValueSet
    Debug.Print cParam.Value
Next

Is the parameter placed on the report anywhere?

If so is that field suppressed?

mlmcc

Free T-shirt

Get a FREE t-shirt when you ask your first question.

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


The field is not suppressed cuz I can view it in Crystal Report.

Avatar of frodomanfrodoman🇺🇸

What data type is the parameter?  The first code snippet you were passing a numeric value, now it looks like you're passing a text value?  Could that be the problem now?

frodoman

Do you have saved data with the report?

Open the report
Click FILE
Ensure SAVE DATA WITH REPORT is turned off

mlmcc

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


The parameter is string type. I did not save the data with the report.

Does the correct vlue print in the debug?

mlmcc

Strange thing is it does....It does print out when viewing in Crystal Report too.

Free T-shirt

Get a FREE t-shirt when you ask your first question.

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


SOLUTION
Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.

Re: this value is write only

I have found the data type is ususally the culprit in this situation.

Have you tried:
CrystalReport.ParameterFields(1).SetCurrentValue CStr( invoiceno )

or

CrystalReport.ParameterFields(1).SetCurrentValue CLng( invoiceno )

Avatar of frodomanfrodoman🇺🇸

Recommend split: EwaldL & mlmcc & frodoman

mlmcc & I got asker over the original question asked.  EwaldL helped with the follow-up question.

mstemen's answer has no relevance.

frodoman

Hope that the points split is fair:)

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.

Crystal Reports

Crystal Reports

--

Questions

--

Followers

Top Experts

Crystal Reports is a business intelligence application from SAP SE. It is used to graphically design data connections and report layouts from a wide range of data sources including Excel spreadsheets, Oracle, SQL Server databases and Access databases, BusinessObjects Enterprise business views, and local file-system information. Report designers can place fields from these sources on the report design surface, and can also deploy them in custom formulas (using either BASIC or Crystal's own syntax), which are then placed on the design surface. Crystal Reports also supports subreports, graphing, and a limited amount of GIS functionality.