on 09-09-2016 12:10 PM
Dear Team,
I have a crystal report in my vb application, which is reflecting all the records on the report, even though I have a SQL query to retrieve only a specific record, But report keep displaying all the records in the table. below is my code, guide me where exactly I am going wrong.
Frm_SCHS_Renewal
Private Sub cmd_save_Click()
//few lines of code for validation and saving data into table
If MsgBox("Do you want to print the DataFlow Group & SCHS Renewal Form ?", vbYesNo, "Print Form") = vbYes Then
Form2.Show
Else
Exit Sub
End If
End Sub
Form2 is containing CRViewer
Form code is as below.
Dim Report As New Rpt_SCHS_RenewalDsr
Private Sub Form_Load()
GetLastID
Dim temp As Integer
temp = lbl_id.Caption
Screen.MousePointer = vbHourglass
SQL = " SELECT id, first_name, mid_name, last_name, date_of_birth, passport_no, email_id, mob_no, app_type, schs_acc_no,
old_ref_no, md, phd, dhs, mem, fellowship, specialist, certificate, bachelor, master, diploma, " _
& " ed_to_varify, major_subject, university_name, college_name, date_issued_certificate, others, ec_to_varify,
employer_name, position, start_date, end_date, hl_to_varify, issuing_aut_name, license_attended, " _
& " license_issue_date From dbo.tbl_schs_renewal WHERE dbo.tbl_schs_renewal.id='" & temp & "' "
connectDB Debug.Print RS.Fields("id") 'just tried to see if query is returning correct row from table and it does return
correct row of data.
With Report
.Database.SetDataSource RS
.PaperOrientation = 1
.PaperSize = 2
.DiscardSavedData
End With
With CRViewer1
.ReportSource = Report
.ViewReport .Zoom (2)
End With
WindowState = 2
Screen.MousePointer = vbDefault
End Sub
Private Sub Form_Resize()
CRViewer1.Top = 0
CRViewer1.Left = 0
CRViewer1.Height = ScaleHeight
CRViewer1.Width = ScaleWidth
End Sub
Public Sub GetLastID()
SQL = "Select MAX(id) from tbl_schs_renewal "
connectDB
With RS
lbl_id.Caption = RS.GetString
End With
connClose
End Sub
I tried getting the result of query in immediate window and the result returned from query is absolutely correct, I mean it is reflecting MAX(id) and related fields from table.
I am not sure why the SetDatasource RS command is not working in my case.
It may be because you are using software that was retired 15 years ago(?). CR 8.5 would not support any current Operating Systems or databases. E.g.; unless you are using something like WIN 3.1 or XP and Access 2.0, you are lucky you got as far as you have...
I recommend moving to 'SAP Crystal Reports, developer version for Microsoft Visual Studio" (CRVS) and VS 2010 or later. CRVS can be downloaded from here:
- Ludek
Senior Support Engineer Product Support, Global Support Center Canada
Follow me on Twitter
Got Enhancement ideas? Use the SAP Idea Place
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Sir,
Thank you for your prompt reply, I truly understand that CR 8.5 is outdated and doesn't work with latest database applications. However it was purely on clients request that I had to develop the application in V.B. 6 and CR 8.5.
I tried some workaround and was successful in getting the desired result. I modified my code and included recordselection formula instead of passing whole record set to the report. Things are looking fine now and working.
Thank you.
User | Count |
---|---|
86 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.