By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 795 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

VB 6.0 to CR 8.5

P: 44
Dear Experts,

i'm trying to display a report based on Start date and End date from VB 6.0.
For report, i use CR 8.5.

Here's my code (VB)

Expand|Select|Wrap|Line Numbers
  1. Private Sub command3_Click()
  2. Dim m_Report As CRAXDDRT.report
  3. Dim m_Application As New CRAXDDRT.Application
  4.  
  5. Set m_Report = Nothing
  6. Set m_Report = m_Application.OpenReport(App.Path + "Report.rpt", 1)
  7.  
  8.     m_Report.ParameterFields.Item(1).AddCurrentValue dt_start.Value
  9.     m_Report.ParameterFields.Item(2).AddCurrentValue dt_end.Value
  10. With CRViewer1
  11.     .EnableExportButton = True
  12.     .EnableCloseButton = True
  13.     .ReportSource = m_Report
  14.     .ViewReport
  15. End With
  16. End Sub
i've made 2 parameters to CR, ?Start and ?End

It works, but it display all datas though, not from the date i input.
Did i make any mistakes?

Thanks in advance..
Jan 8 '08 #1
Share this Question
Share on Google+
6 Replies


debasisdas
Expert 5K+
P: 8,127
instead of using paramet object try to pass the sql string directly to the crystlreport using SQLQueryString
Jan 8 '08 #2

debasisdas
Expert 5K+
P: 8,127
try to use like this

Expand|Select|Wrap|Line Numbers
  1. Public Sub ReportDisplay(Query As String)
  2.  
  3. Set CRXReport = visitordetails
  4. Set CRXDb = CRXReport.Database
  5. CRXReport.DiscardSavedData
  6.  
  7. inti = 1
  8. Do Until inti = CRXReport.Database.Tables.Count + 1
  9. CRXReport.Database.Tables.Item(inti).SetLogOnInfo strdblocation, "das", "debasis", "debasis"
  10. inti = inti + 1
  11. Loop
  12.  
  13. visitordetails.SQLQueryString = Query
  14.  
  15. With FrmReport1
  16. .Show
  17. .CRV1.ReportSource = CRXReport
  18. .CRV1.ViewReport
  19. End With
  20.  
  21. Set CRXReport = Nothing
  22. End Sub
  23.  
  24.  
Jan 8 '08 #3

QVeen72
Expert 100+
P: 1,445
Hi,

Instead of Parameters, use RecordSelection Formula..

Check This :

Expand|Select|Wrap|Line Numbers
  1. Private Sub command3_Click()
  2. Dim m_Report As CRAXDDRT.report
  3. Dim m_Application As New CRAXDDRT.Application
  4.  
  5. Set m_Report = Nothing
  6. Set m_Report = m_Application.OpenReport(App.Path + "Report.rpt", 1)
  7. m_Report.RecordSelectionFormula = {MyTable.DateFld} In Date(" _
  8.   & Format(dt_start.Value, "yyyy,mm,dd") & ") To Date(" _
  9.   & Format(dt_end.Value,"yyyy,mm,dd") & ")" 
  10. With CRViewer1
  11.     .EnableExportButton = True
  12.     .EnableCloseButton = True
  13.     .ReportSource = m_Report
  14.     .ViewReport
  15. End With
  16. End Sub


Regards
Veena
Jan 8 '08 #4

P: 44
To debasisdas, im using Ms Access though, sorry for forget telling..
To Ms Veena, it is error =(
Jan 8 '08 #5

QVeen72
Expert 100+
P: 1,445
Hi,

Sorry, I forgot the Starting Double quote:

Expand|Select|Wrap|Line Numbers
  1. m_Report.RecordSelectionFormula = "{MyTable.DateFld} In Date(" _
  2.   & Format(dt_start.Value, "yyyy,mm,dd") & ") To Date(" _
  3.   & Format(dt_end.Value,"yyyy,mm,dd") & ")" 
  4.  
Regards
Veena
Jan 8 '08 #6

P: 44
Thanks so much, Ms.Veena, it really works..
I put the code like this

Expand|Select|Wrap|Line Numbers
  1. Private Sub command3_Click()
  2. Dim m_Report As CRAXDDRT.report
  3. Dim m_Application As New CRAXDDRT.Application
  4.  
  5. Set m_Report = Nothing
  6. Set m_Report = m_Application.OpenReport(App.Path + "Report.rpt", 1)
  7.  
  8.     m_Report.RecordSelectionFormula = "{printLap.Date} In Date(" & Format(dt_start.Value, "yyyy,mm,dd") & ") To Date(" & Format(dt_end.Value, "yyyy,mm,dd") & ")"
  9.  
  10.     m_Report.ParameterFields.Item(1).AddCurrentValue dt_start.Value
  11.     m_Report.ParameterFields.Item(2).AddCurrentValue dt_end.Value
  12.  
  13.  
  14.     With CRViewer1
  15.     .EnableExportButton = True
  16.     .EnableCloseButton = True
  17.     .ReportSource = m_Report
  18.     .ViewReport
  19. End With
Thanks............ ;-)
Jan 10 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.