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

Crystal Report 4.6

Status
Not open for further replies.

ICTECH

Technical User
Jun 5, 2002
131
CA
I have a report that I'm wanting to be able to change the Date the report is looking in the Database for the in information. But I can't seem to get it to work. When I hard incode a date into the file it will display the information.

Was wondering if anyone had any ideas on how to get a VB6 app to give the Date to the report at run time???

Been trying to use:

CrystalReport.SelectionFormula = "{Bookings.Date} = 6/24/2002"

But I get the following error message:

Error in Formula.

Thanks for any help ya me have to offer....

 
What database are you using as the date source? If it's Access, for example, you'll need to place #s before and after the field...
 
Hi earljgray...

The datasource is MS Access. The "#" woul;d go like this?

CrystalReport.SelectionFormula = #"{Bookings.Date} = 6/24/2002"#

I'm giving myself a crash cource in this.. THanks for any help you can give..
 
The entire SelectionFromula value is a string enclosed in quotes. Within thgat string, the date value is enclosed in #'s -- like this:
CrystalReport.SelectionFormula = "{Bookings.Date} = #6/24/2002# "
 
Hi Rogar...

Thanks.. I tried it and still get the run-time error '20515' Error in formula. Not sure that I'm doing wrong.. Hmmm... Could there be something wrong with the report file? Is there anything special that I would have to do in its design??

Thanks again...
 
I have a feeling that this, #6/24/2002# , is not an allowed date format in Crystal 4.6

I'm not sure how dates are passed in VB but using

date({Table.date},"yyyyMMdd")

might work better Jim Broadbent
 
Hi Ngolem...

I will try that and let you know.. Thanks again...

 
I would try

CrystalReport.SelectionFormula = "{Bookings.Date} = Date(2002,6,24)"

That is the original format for a date literal Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Hi Ken...

I tried that out and I'm still getting a blank report being displayed.

I'm not sure what to try next.. I can only come up with something's not right about the report file.. Hmmmm


 
what if you don't pass ANY formula, does the report display? Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Hi Ken..

Sorry for not getting back to you sooner.. Been on Holidays...

THe Report does display when I take out any passing of data from VB to the report..

 
Make sure that the report isn't saved with data.
Also open the report in the report designer and confirm that CR recognizes this field as a true date field.
Can you pass a selection formula that uses a different field?
Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Hi Ken...

I checked the Date Field and as far as I can tell, CR is seeing it as a Date Field. I can create a text field and pass data from VB to it and it displays in the report.

The code is as follows that I'm trying...

tmpDate = FORMAT(tmpDate, "yyyy,mm,dd")

With CrystalReport1
.ReportFileName = app.path & "\test.rpt"
.DiscardSavedData = True
.Destination = crptToWindow
.SelectionFormula = "{Bookings.Date} =" & tmpDate
.Action = 1
End With

END of Code...

When I run it I get the following Error Message..

" Run-Time error '20515': Error in Formula. "

I've been hunting on the Web, but there is not much out there on version 4.6..

Thanks for your help...
 
tmpDate = FORMAT(tmpDate, "yyyy,mm,dd")
With CrystalReport1
...
.SelectionFormula = "{Bookings.Date} = Date(" & tmpDate & ")"
.Action = 1
End With
 
ICTECH, rogar's syntax is what I was pointing you to when I had to test the following:

CrystalReport.SelectionFormula = "{Bookings.Date} = Date(2002,6,24)"

You said that you got a blank report. Did you get an error message or just no records? No records returned may mean that none of the records met the criteria, but that the syntax is correct.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Hi Everyone..

Thanks for the HELP...

It now works..

Don't exactly know why it wasn't working. I retyped in the SelectFormula line and wa-la it desided to work..

Ken, When I put in (2002,6,24) inplace of the variable name, I did net a blank report form being displayed and no error messages.

Thanks again for all the great ideas to try...
 
That usually means that it got a criteria formula correctly, but found nothing to match it. Glad it is working. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Hi Ken...

I did notice somehtin when the report was displayed. Not all of the report was displayed. In Design View, I had it grouping the data by Driver Name and only displaying the Driver's pickups for the date given. But when VB6 displayed the report. It only shows one driver when there are two. THe Design View in Crystal Report 4.6 shows the two for the given date, but again, when VB displays the same file it only has the one.. Hmmm....

An Ideas?
 
Is that one driver complete - showing the exact same records as you see within CR? Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Hi Ken...

Yes, the report is showing the first part of the report properly, but the second part is not. Does VB6 and CR 4.6 have some quork about displaying Grouping of data?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top