Results 1 to 5 of 5

Thread: crystal report and textbox command

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    3

    crystal report and textbox command

    hi everybody.

    I've been searching on this but can't seem to find the answer.

    I have an access database with a table called tblDVD. This table has a field called 'actief' where the last date a dvd has been ordered is stored in. If a DVD hasn't been ordered the field is empty.

    Now, I have to make a crystal report where the user first gives two dates (a start date and end date) in a textbox, and then the report should only show the DVD's who have been ordered between those dates.

    I can't seem to find how to link the date input and the crystal report. Could anyone help me?

    thanks.

  2. #2
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036

    Re: crystal report and textbox command

    hi
    Try this
    VB Code:
    1. formula = "{table.field1} >= " & date1 & " and {table.field2} <= " & date2
    2. crReportDocument.RecordSelectionFormula = formula
    Jorge
    "The dark side clouds everything. Impossible to see the future is."

  3. #3
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339

    Re: crystal report and textbox command

    You could pass the parameters to the crystal report, you could fill a dataset with the filtered data and pass the dataset to the crystal report, or you could use the formula/parameter fields in crystal reports.

  4. #4

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    3

    Re: crystal report and textbox command

    Code:
     Private Sub bestverkopend_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim rpt As New CrystalReport2
            Dim dat1 As String = txtdat1.Text
            Dim dat2 As String = txtdat2.Text
    
            Dim datum1 As Date
            Dim datum2 As Date
            datum1 = dat1
            datum2 = dat2
            datum1.ToShortDateString()
            datum2.ToShortDateString()
    
    
            'Dim mySelectFormula As String = "{tblDVD.actief} >= Date(2006,05,06) " _
            '& "AND {tblDVD.actief} <= Date(2006,05,12) "
            Dim mySelectFormula As String = "{tblDVD.actief} >= datum1 " _
            & "AND {tblDVD.actief} <= datum2 "
    
    
            CrystalReportViewer1.SelectionFormula = mySelectFormula
            'Dim reportPath As String = 
            'Application.StartupPath & "\" & "CrystalReport2.rpt"
            CrystalReportViewer1.ReportSource = rpt
    
            CrystalReportViewer1.ShowGroupTreeButton = False
    I get "error in formula <record selection>"{tblDVD.actief} >= datum1 " _
    & "AND {tblDVD.actief} <= datum2 "
    a number, currency, amount boolean, date, time, date-time or string is expected here.



    any help its quite urgent.
    Last edited by eaurouge; May 15th, 2006 at 04:04 PM.

  5. #5

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    3

    Re: crystal report and textbox command

    any help please?? I keep getting an error on da.Fill(ds, "dvds")
    and if I just use select * from tblDvd ther's nothing in my crystal report

    Code:
       Private Sub bestverkopend_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            '     Dim rpt As New CrystalReport1
            '     Dim ds As New Dataset1  'de DataSet die'k gemaakt hebt
    
            '     Dim cnn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
            '& vars.db)
    
    
            '     Dim da As OleDbDataAdapter = New OleDbDataAdapter("Select id, omschrijving, actief, atlActief from tblDvd where actief >= DataTimePicker1.value1 and actief <= DataTimePicker2.value", cnn)
            '     da.Fill(ds, "dvds")
            '     rpt.SetDataSource(ds)
            '     CrystalReportViewer1.ReportSource = rpt
    
            Dim rpt As New CrystalReport1
    
            Dim ds As New Dataset1  'de DataSet die'k gemaakt hebt
    
            Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
                    & vars.db
            Dim myConnection As OleDbConnection = New OleDbConnection
            myConnection.ConnectionString = connString
    
            Label1.Text = DateTimePicker1.Value
            Label2.Text = DateTimePicker2.Value
           
            'where actief between  and DateTimePicker1.value
            Dim da As OleDbDataAdapter = New OleDbDataAdapter("Select * from tblDvd where actief >= DateTimePicker1.value and actief <= DateTimePicker2.value", myConnection)
            'Dim da As OleDbDataAdapter = New OleDbDataAdapter("select * from tblDvd where actief >= #2006-01-01# and actief <= #2006-12-12#", myConnection)
            Try
                da.Fill(ds, "dvds")
            Catch ex As Exception
                MsgBox(ex.Message())
            End Try
    
            rpt.SetDataSource(ds)
            CrystalReportViewer1.ReportSource = rpt
    
    
        End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width