passing null parameter to crystal reports

Edy

New member
Joined
Oct 25, 2006
Messages
3
Programming Experience
1-3
VB.NET:
Private Sub BPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BPrint.Click
Dim frm As New FrmPrintReport 'reports
Dim cr As New CRepResponsable
cr.SetParameterValue(0, Val(Me.TBAccountNumber.Text))'integer
cr.SetParameterValue(1, Me.TBAccountNumber.Text)'string
cr.SetParameterValue(2, vbNull) 'integer
cr.SetParameterValue(3, vbNull) 'string
 
frm.CrystalReportViewer.ReportSource = cr
frm.MdiParent = Me.MdiParent
frm.Show()
End Sub
i have the code above. i could not pass a null parameter, to the crystal reports. i will have an empty report
smiley_cry.gif
i tried vbnull.null and vbnull.empty same result.
but if I put
VB.NET:
cr.SetParameterValue(2, Val(Me.TBSubAccount.Text))) 'integer 'not null
cr.SetParameterValue(3, Me.TBSubAccount.Text) 'string 'not null
the report display the values.
here is the select expert formula (CR):
VB.NET:
{CUSTOMERS.SUB_ACCOUNT_NUMBER} = {?SubAccount_String} and
{ecole.serial} = {?AccountNumber} and
{CUSTOMERS.ACCOUNT_NUMBER} = {?AccountNumber_String} and
{ecole.sub_account} = {?SubAccount}
How could i pass a null parameter?
 
Do you have the AccountNumber in the database with null value? I think you pass the null value to your expert formula, it will become like this

VB.NET:
{ecole.serial} = NULL

May be modify the expert formula will do

VB.NET:
{ecole.serial} Like IIF({?AccountNumber} Is Null, "%", {?AccountNumber})

Something like that.
 
thanx lingsn for your reply
i couldnt set the {ecole.serial} = NULL => syntax error.
anyway i resolved the problem by creating 2 crystal reports files, one with subaccount parameter the other without them
 
Back
Top