|
-
Sep 15th, 2000, 02:20 PM
#1
How do I construct a SelectionFormula that uses a date in VB? I am using SQL Server 6.5.
My VB6 code looks like this:
Private Sub cmdPrint_Click()
Dim rptSql As String
Dim rptDate As Date
rptSql = "SELECT * FROM CheckRegister WHERE {CheckRegister.bank_statement_date}=Date('"
rptSql = rptSql & cboStatementDate.Text + "')"
CrystalReport1.SelectionFormula = rptSql
CrystalReport1.Action = 1
End Sub
I have tried many variations on this formula, such as using the string variable alone, in quotes, and using a date variable instead of a string variable, but nothing seems to work. I keep getting the error message "The remaining text does not appear to be part of the formula".
Does the date have to converted to a different format?
If any one has a solution, I would greatly appreciate it.
-
Sep 15th, 2000, 02:56 PM
#2
Excuse me if I am wrong, but doesn't you have to put the string in the -->CrystalReport.SqlQuery<---
or something like that.
This if You are using Crystalreports that came with VS.
-
Sep 15th, 2000, 03:19 PM
#3
Lively Member
Parameters for function Date() in Crystal Reports are 3: year, month and day. You can use:
Code:
rptSql = "{CheckRegister.bank_statement_date}="
rptSql = rptSql & "Date(" & Year(cboStatementDate.Text) & ", " & Month(cboStatementDate.Text) & ", " & Day(cboStatementDate.Text) & ")"
Hope it works!
[Edited by JMuller on 09-15-2000 at 04:22 PM]
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
|