how can I solve this kind of error: "a number, currency amount, boolean, date, time, date-time, or string is expected here"
here is my code:

Dim oDoc As New ReportDocument
        oDoc.Load("D:\updated 2-21-cla-12-57\WAIS SYSTEM\WAIS SYSTEM\GUIDANCE-dropRpt.rpt")

        Dim myDS As New DataSet
        oDoc.SetDataSource(myDS.Tables("drop_student"))

        Select Case GUIREP_drop.Search.SelectedItem
            Case "Date"
                strsql = "{drop_student.date_drop} = '" & GUIREP_drop.search_student.Text & "'"
            Case "Section"
                strsql = "{drop_student.Section} = '" & GUIREP_drop.searchtype.Text & "'"
            Case "Student ID"
                strsql = "{drop_student.Dropstud_no} = " & GUIREP_drop.search_student.Text.ToString & ""
        End Select

        CrystalReportViewer1.SelectionFormula = strsql
        CrystalReportViewer1.ReportSource = oDoc

any response is appreciated :)

hello !
here is an error

Case "Student ID"
      strsql = "{drop_student.Dropstud_no} = " & GUIREP_drop.search_student.Text.ToString & ""
'because student_id or student no is numeric vlaue , and you are using tostring . use this code 
            Case "Student ID"
                strsql = "{drop_student.Dropstud_no} = " & val(GUIREP_drop.search_student.Text)

Hope this will solve your prob :) .if yes please vote me up and mark your thread solved :)

Best Regards

Edited 4 Years Ago by M.Waqas Aslam: n/a

I did it this way:

Case "Student ID"
                strsql = "{drop_student.Dropstud_no} = " & Val(GUIREP_drop.search_student.Text) & ""

I also try this way:

Case "Student ID"
                strsql = "{drop_student.Dropstud_no} = " & Val(GUIREP_drop.search_student.Text)

it has the same error ( "a number, currency amount, boolean, date, time, date-time, or string is expected here")

here's the full code:

Private Sub GUIDANCE_droprptFRM_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim oDoc As New ReportDocument
        oDoc.Load("D:\updated 2-21-cla-12-57\WAIS SYSTEM\WAIS SYSTEM\GUIDANCE-dropRpt.rpt")

        Dim myDS As New DataSet
        oDoc.SetDataSource(myDS.Tables("drop_student"))

        Select Case GUIREP_drop.Search.SelectedItem
            Case "Date"
                strsql = "{drop_student.date_drop} = '" & GUIREP_drop.search_student.Text & "'"
            Case "Section"
                strsql = "{drop_student.Section} = '" & GUIREP_drop.Search.Text & "'"
            Case "Student ID"
                strsql = "{drop_student.Dropstud_no} = " & Val(GUIREP_drop.search_student.Text)
        End Select

        CrystalReportViewer1.SelectionFormula = strsql
        CrystalReportViewer1.ReportSource = oDoc
    End Sub
This article has been dead for over six months. Start a new discussion instead.