SelectionFormula - Multiple Range and Multiple Type

gchwee
04-16-2004, 07:21 PM
dim m, a, b, name, datein, dateend

name = text3.text
datein = text1.text
dateend = text2.text
m = text4.text

'ERROR 1:
Report1.RecordSelectionFormula = "{Table1.name} =" & name & "AND {Table1.date} IN Date(" & a &") To Date(" & b &")"


'ERROR 2:
Report1.RecordSelectionFormula = "{Table1.name} =" & name & "AND month({Table1.date} in [" & m &"," & m & "])"


I allow the user to key in the "date range"/"month" + name in vb, then pass the selectionformula to the crystal report designed.
For example1: name = KEN, a = 2003, 12, 31 , b = 2003, 01, 31
then the report will print out the customer name equal to KEN and transaction during the period.

For example2: name = Steven, m = 2
then the report will print out the customer name equal to Steven and transaction during February.

Anyone can help? :)

MKoslof
04-16-2004, 07:27 PM
Are you running this from VB? I assume so, NOT from Crystal reports, try this instead:

Also, are you using Access, if so,use #'s around your Dates.

The Date() and ToDate() parameters are native Crystal functions. If you are using the Active X Crystal Design and Runtime library (CRAXDRT), this should work:




Dim sSQL as string 'add another string


myName = text3.text
datein = CDate(text1.text)
dateend = CDate(text2.text)

sSQL = "{Table1.name} = '" & myname & "' AND {Table1.date} BETWEEN #" & dateIn & "# AND #" & dateend & "#"

Report1.RecordSelectionFormula = sSQL

gchwee
04-17-2004, 12:57 AM
Well. sir, :) Yes.I running this from VB6.0. I also using the Access. And I did set my crystal report's database connection to ADO. Yes, And I using the Active X Crystal Design Library(CRAXDRT). But the coding is not work.

ERROR MSG: The Field name is not known
Private Sub Form_Load()
Dim crxApp As New CRAXDRT.Application
Dim Report1 As New CRAXDRT.Report
Dim myname As String
Dim sSQL As String
Dim datein, dateout
Screen.MousePointer = vbHourglass
Set Report1 = crxApp.OpenReport(App.Path & "\ChuHuoSub.rpt")
myname = (ReportMenu.Text1.Text)
datein = CDate(ReportMenu.Text2.Text)
dateout = CDate(ReportMenu.Text3.Text)
Report1.DiscardSavedData
sSQL = "{ChuHuo.Name} = '" & myname & "' AND {ChuoHuo.Date} BETWEEN #" & datein & "# AND #" & dateout & "#"
Report1.RecordSelectionFormula = sSQL 'error here
MsgBox Report1.RecordSelectionFormula
CRViewer91.ReportSource = Report1
CRViewer91.ViewReport
CRViewer91.Zoom 94
Screen.MousePointer = vbDefault
End Sub

MSGBOX show that--> {ChuHuo.Name} = 'ken' AND {ChuHuo.Date} BETWEEN #1/1/2003# AND #2/1/2004#

Not matter how, Thanks for your help, sir. :)

MKoslof
04-19-2004, 07:30 AM
If you are using ADO, your tables might be aliased automatically. If you open your report in design view and look at the fields, do they say {ADO.Name}, {ADO.field1}, etc? If so, you need to reference the current name of the table as assigned by Crystal. So:

{ADO.Name} and {ADO.Date}

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum