|
-
Dec 5th, 2000, 09:08 PM
#1
Thread Starter
New Member
I have VB 5.0 and Crystal 4.6xxx. I am trying to select records in my database to pass on to crystal reports. I am inputting a start date and an end date. and trying to get it to print the report. I keep getting an "error in formula".
Can anyone please HELP.
I have include my code below.
Dim stdte As Date
Dim endte As Date
Private Sub Command1_Click()
stdte = startdate.Text
endte = enddate.Text
Number_of_copies = "1"
Outputlist = "Printer"
OutputDestination = 2
Report4.CopiesToPrinter = Number_of_copies
Report4.Destination = OutputDestination
FmlaText$ = "{data.dte} in + Trim(startdate.text) + to + Trim(enddate.text) + "
Report4.SelectionFormula = FmlaText$
On Error GoTo ErrorHandler
Report4.Action = 1
Unload frmgrspft
frmDocument.Show
Exit Sub
ErrorHandler:
MsgBox error$
Exit Sub
End Sub
Private Sub Form_Load()
startdate.Text = "11/1/2000"
enddate.Text = "12/1/2000"
End Sub
-
Dec 6th, 2000, 10:06 AM
#2
Frenzied Member
Your problem is in one of two places:
FmlaText$ = "{data.dte} in + Trim(startdate.text) + to + Trim(enddate.text) + "
(this formula definitely has an error, the last '+' should not be there)
and/or
You have an error in a formula field in the rpt file itself, in which case, you'd probably be on your own to fix since you can't really post that in any meaningful way.
Try fixing your selection formula first and see if that does it. If not, you'll need to check the rpt file's formula fields. If you go into each one and save, it will alert you to any errors in the formula itself.
BTW- STOP USING 4.6!!! it's utter crap.
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
-
Dec 6th, 2000, 10:22 AM
#3
Thread Starter
New Member
VB and Crystal reports
I have tried taking out the '+' at the end, still no help. There is no formula in the rpt file itself. What it is "supposed" to do is get all records between the two dates and send the data to crystal report. Is there a way I could pass these date to crystal and do the formula inside crystal?
Thank You in advance for your help.
BTW Crystal 4.6 is all I got, Sorry.
-
Dec 6th, 2000, 10:50 AM
#4
Frenzied Member
From Seagate's help file:
Any dates that are being passed to Seagate Crystal Reports must be in Seagate Crystal Reports Date format, Date(yyyy,mm,dd).
Also, I just looked more closely at your formula:
Code:
'Should read like:
FmlaText$ = "{data.dte} in + " & Trim(startdate.text) & " + to + " & Trim(enddate.text)
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
-
Dec 6th, 2000, 11:43 AM
#5
Thread Starter
New Member
Still get that stinking "error in formula"
Any other suggestions besides using a hammer.
Thanks,
bdw72
-
Dec 6th, 2000, 05:19 PM
#6
Frenzied Member
Ok, here is the scoop.
In order to use the 'in' keyword in this way, you have to use one of Crystal's built in date range variables. If you want to limit records based on static dates (which appears to be what your doing) you need to do something like this:
Code:
FmlaText$ = "{data.dte} >= CDate('" & Trim(startdate.text) & "') and {data.dte} <= CDate('" & Trim(enddate.text) & "')"
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
-
Dec 6th, 2000, 09:29 PM
#7
Thread Starter
New Member
still getting error in formula? I have other print functions working with the same type of code, but they are not comparing any dates.
Thanks for all your help
bdw72
-
Dec 6th, 2000, 10:08 PM
#8
Try this...
First design the Report in Crystal as though Crystal was the only software that your going to use for the report.
Then, once that's finished load your Visual Basic. Design a for, if you haven't already done so, that you will select your reports from.
Then open up your dialog box for your COMPONENTS. (accessed from the bottom of your project menu)
You should see listed Crystal Reports. you might have to register it though. if you have to register Crystal with VB then simply click the Browse button and go find the file displayed at the bottom of the Components dialog window.
Then, once you click apply, you'll see the Crystal Reports component appear on your tool bar thingy.
Simply click the Crystal Reports button and draw one on your form. You can then place a list of all your reports into a list box and code so that when the user double-clicks one of the items in the list box, the appropriate reports will be blasted out of your selected printer!!!
Oh, and you'll also have to put one Crystal Reports Control onthe form for each report that you want to have available. You can simply make a control array and then pass the indexes along as neeed to reduce the amount of code you'll have to write...!
best of luck.
-
Dec 7th, 2000, 11:00 AM
#9
Frenzied Member
What I would suggest to do, is open up Crystal with your report file open and go to the 'Report/Edit Selection Formula/Detail' Menu, and type in your selection formula the way you have it in your code (obviously replace any variables with literals for this). Try to save it and see if you get an error then. If you do, it may give you more of an error message than you are getting from VB.
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|