date - DB - Crystal Report 
Author Message
 date - DB - Crystal Report

I want to pick records from a DB to display in a Crystal Report:

The .mdb contains a datefield.

I want the user to put a date in a text (Txt1.Text) and another in a
second Text.

The report should make a selection formula:

SelectionFormula = Database.Date = from text1 to text2

I managed to make something similar (with much help from a reader of
this newsgroup but that case concerned comparision of a text-field in
the DB with a textfield in the form and was more simple.

My problem is how to convert the texts from the form in to valid dates
that can be compared with both the database (.mdb) and the
reportfields.



Mon, 05 Jul 1999 03:00:00 GMT  
 date - DB - Crystal Report

Quote:

> I want to pick records from a DB to display in a Crystal Report:
> The .mdb contains a datefield.
> I want the user to put a date in a text (Txt1.Text) and another in a
> second Text.
> The report should make a selection formula:
> SelectionFormula = Database.Date = from text1 to text2
> I managed to make something similar (with much help from a reader of
> this newsgroup but that case concerned comparision of a text-field in
> the DB with a textfield in the form and was more simple.
> My problem is how to convert the texts from the form in to valid dates
> that can be compared with both the database (.mdb) and the
> reportfields.

Mats,

I normally use the method shown in this snippet of code:

   nDays1% = Now - CVDate(fpStartDate.Text)
   nDays2% = Now - CVDate(fpEndDate.Text)

   If nDays2% <= nDays1% Then
         prtPaidInv.ReportFileName = AppPath$ & "PAIDINV.RPT"
         prtPaidInv.DataFiles(0) = AppPath$ & "GMPS.MDB"
         prtPaidInv.SortFields(0) = "+{tblPomaster.Pname}"
         prtPaidInv.SortFields(1) = "+{tblPomaster.Date_Paid}"
         prtPaidInv.SelectionFormula = "{tblPomaster.DATE_PAID} >= Today - " & nDays1% & " and {tblPomaster.DATE_PAID} <= Today - " & nDays2%
         prtPaidInv.Destination = 0
         prtPaidInv.Action = 1

............

This is a simpler way of passing dates to Crystal and seems to work
for me.

Hope this helps.

Cheers,

Fred
Fred A. Brunings
WATTLE PARK SA 5066
AUSTRALIA



Sat, 17 Jul 1999 03:00:00 GMT  
 date - DB - Crystal Report


Quote:
Brunings) writes:
>> I want to pick records from a DB to display in a Crystal Report:

>> The .mdb contains a datefield.

>> I want the user to put a date in a text (Txt1.Text) and another in a
>> second Text.

>> The report should make a selection formula:

>> SelectionFormula = Database.Date = from text1 to text2

>> I managed to make something similar (with much help from a reader of
>> this newsgroup but that case concerned comparision of a text-field in
>> the DB with a textfield in the form and was more simple.

>> My problem is how to convert the texts from the form in to valid dates
>> that can be compared with both the database (.mdb) and the

Here's how I choose all records between two dates (text fields):  FROM and
TO.  Notice the required formats for the dates when using a selection
formula in CR:

Private Sub Command1_Click(Index As Integer)
    Dim DateFrom As String, DateTo As String

    If Index = 0 Then
        If txtFrom.DataChanged Or txtTo.DataChanged Then
datDate.UpdateRecord
        If ReportType = "Income" Then
            frmMain.CRPE.ReportFileName = App.Path + "\income.rpt"
        Else
            frmMain.CRPE.ReportFileName = App.Path + "\distrib.rpt"
        End If

        frmMain.CRPE.DataFiles(0) = Current_Database

        If Trim(txtFrom.Text) = "" Then
            DateFrom = Format("11/30/1970", "yyyy,mm,dd")
        Else
            DateFrom = Format(txtFrom.Text, "yyyy,mm,dd")
        End If

        If Trim(txtTo.Text) = "" Then
            DateTo = Format(Now, "yyyy,mm,dd")
        Else
            DateTo = Format(txtTo.Text, "yyyy,mm,dd")
        End If
        frmMain.CRPE.SelectionFormula = "{Main.Da{*filter*}tered} >= Date(" +
DateFrom + ") and {Main.Da{*filter*}tered} <= Date(" + DateTo + ")"
        frmMain.CRPE.Action = 1
    Else
        Unload Me
    End If
End Sub



Sat, 17 Jul 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Crystal Report Date Vrs Sql Server Date

2. Crystal Reports 8.5 date range parameter field - record selection that includes null date range

3. CRYSTAL REPORT, run time query report by date

4. Printing Crystal Reports without Crystal Control ActiveX or Crystal Reports API call

5. Date problem and Reports from a DB...Help!!

6. Crystal Reports and Path to DB

7. Help with Crystal Reports and Access DB

8. Connect a db to a crystal report

9. Crystal Report object linking to Db problem

10. changing db location in ODBC for Crystal Report at runtime

11. Location Of DB in VB for Crystal Reports

12. Urgent! Attaching DB to Crystal Report at runtime

 

 
Powered by phpBB® Forum Software