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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Could not passed value from VB to crystal report 1

Status
Not open for further replies.

nDAa

Programmer
Mar 1, 2005
14
TH
Hi,All

I have a problem when i pressed print button. The value could not passed to parameter in crystal report and the prompt wait for user input data in crystal report screen. Advice me please me.


Private Sub cmdPrint_Click()
RptPrint.Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" & "DATA SOURCE=C:\centerS\Material_Receipt.MDB"
RptPrint.ReportFileName = App.Path & "\Report\Mat_Recei.rpt"
RptPrint.ParameterFields(0) = "comp;" & Trim(Aft_extract_id(cmbCompany.Text)) & ";True"
RptPrint.ParameterFields(1) = "docno;" & Trim(txtNumber.Text) & ";True"
RptPrint.WindowState = crptMaximized
RptPrint.WindowShowGroupTree = False
RptPrint.WindowShowExportBtn = True
RptPrint.WindowAllowDrillDown = True
RptPrint.WindowShowPrintBtn = True
RptPrint.WindowShowPrintSetupBtn = True
RptPrint.WindowShowRefreshBtn = True
RptPrint.DiscardSavedData = True
RptPrint.Action = 1
END sub

In crystal report I created 2 parameter are (?comp,?Docno)and have a select formula record as
{Trans_MatRecei.Comp_code} = {?comp} and
{Trans_MatRecei.Doc_NO} = {?docno}

Remarks : using vb6 and crystal report 7

Thanks advance
Ndaa



 
Ndaa

in order to pass values from VB to Cyrstal you can use the
.SelectionFormula in your code. For example: -

RptPrint.SelectionFormula="{Trans_MatRecei.Comp_code} = " & Trim(Aft_extract_id(cmbCompany.Text)) & " AND {Trans_MatRecei.Doc_NO} = " & Trim(txtNumber.Text)

I find it easier to have a public function for previewing reports, you can then use one function and pass the report name, data source, selection criteria and so on to this one function.

Rgds


 
Hi,DarrellW

Thank you for your help.I used to using .Selectionformula as

RptPrint.SelectionFormula = "{Trans_MatRecei.Comp_code} = '" & Trim(cmbCompany.Text) & "' and {Trans_MatRecei.Doc_NO} = '" & Trim(txtNumber.Text) & "'"

Program display error message as : Run time error 20553
Invalid parameter field name

I sure the field name in table is valid.A table name is Trans_MatRecei and have 3 field name (comp_code,supp_code,doc_no all to be text)

and then i debug the value in selectionformula,it's show the value as:
{Trans_MatRecei.Comp_code}='NPA' and {Trans_MatRecei.Doc_NO}='01'

Could you give me any comment.


Appreciated for your help.
Ndaa


 
If there's anything currently in the report's Record Selection Formula, using the SelectionFormula property will append to the existing formula. Instead, try using the ReplaceSelectionFormula method:

RptPrint.ReplaceSelectionFormula ("{Trans_MatRecei.Comp_code} = '" & Trim(cmbCompany.Text) & "' and {Trans_MatRecei.Doc_NO} = '" & Trim(txtNumber.Text) & "'")

-dave
 
Hi,vidru

Thanks you so much.I'm using the ReplaceSelectionFormula is OK.

Rgds
Ndaa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top