Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

display field items in crystal report

Status
Not open for further replies.

santosh1

Programmer
Apr 26, 2002
201
US
I selected the field items from the fields explorer table in crystal report. When I run the report, the field items are not displayed. How do I display the fields from the table in the fields explorer?

Thanks in advance.
 
When you say "I selected the field items from the field explorer" what do you mean? Please tell me eactly what you did.

Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
 
Did you put these items on the "details" band?

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Tips and Tricks / Guide to Crystal in VB
- tek@kenhamady.com
 
In Crystal 8.5., you select field items and place them somewhere on the report. Normally the detail line, but it's up to you and Crystal won't warn you.

Another method is to create formual fields using the Field Explorer, and then place those on the detail line (or wherever else you want them). The advantage of formula fields is that you don't have to display exactly what's there, and can also test for nulls, e.g.
if isnull ({your.field})
then "Nulls"
else {your.field}

Having come to Crystal from mainframe languages, I got very confused by Nulls at first. A null means an absence of data, as distinct from zero or space which implies definite knowledge of zero value or a value not applicable. And Crystal will produce nothing when it encounters a null, unless nulls are first tested for.

Madawc Williams
East Anglia, Great Britain
 

Thanks all for the suggestions. This is my first time using Crystal Report, and I do
appreciate all your help very much.

I put the database fields in the details section from the field
explorer, still the field items are not displayed in
the Crystal Report when I run the report. I checked the database table if it has the field items
that I want to display, and it does. Since the field items that I place in crystal report is from
this table, I thought it should be displayed when I run the report.
Below is a sample code from the load event of crystal report viewer.
Is there something in the code or am I doing it right?
What can I do to display the field items in the report? Thanks much in advance.



Private Sub CrystalViewer_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CrystalViewer.Load, MyBase.Load
Dim rpt As New CrystalReport1()
Dim myconnection As OleDbConnection
Dim mycommand As New OleDbCommand()
Dim myDA As New OleDbDataAdapter()
Dim myDS As New DataSet()
Dim strSQL As String
Dim conn As OleDbConnection

strSQL = "SELECT StreetAddress, City, State, Zipcode, Country "
strSQL += "FROM Employee_Address"

Try

conn = New OleDbConnection(mvarConnectionString)


myDA = New OleDbDataAdapter(strSQL, mvarConnectionString)
conn.Open()



myDA.Fill(myDS, "Crystal Report")
rpt.SetDataSource(myDS)

Dim tbCurrent As CrystalDecisions.CrystalReports.Engine.Table
Dim tliCurrent As CrystalDecisions.Shared.TableLogOnInfo

For Each tbCurrent In rpt.Database.Tables
tliCurrent = tbCurrent.LogOnInfo
With tliCurrent.ConnectionInfo
.ServerName = " "
.UserID = " "
.Password = " "
.DatabaseName = " "
End With
tbCurrent.ApplyLogOnInfo(tliCurrent)
Next tbCurrent

CrystalReportViewer.ReportSource = rpt
CrystalReportViewer.Visible = True
CrystalReportViewer.Zoom(100)
CrystalReportViewer.RefreshReport()

Catch ex As OleDbException
MsgBox(ex.Message, MsgBoxStyle.Critical, "SQL Error")
Exit Sub

Catch exc As Exception
' Unable to connect to SQL Server
MessageBox.Show("Bind Data Grid Failed.")
Exit Sub
Finally
rpt.Dispose()
conn.Close()
conn.Dispose()
myDS.Dispose()
myDA.Dispose()
End Try

End Sub





 
You are passing a dataset, and then trying to log into the table. I don't think you want to both. If you are going to pass a dataset, make sure it is populated before you pass it.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Tips and Tricks / Guide to Crystal in VB
- tek@kenhamady.com
 
I removed the dataset, but when I run the report,
it still doesn't show the field values. I did browse field data, and the value that I want to display is there, it's not empty. Am I missing something? Following is what I have on the crystal viewer load event.

Private Sub CrystalViewer_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CrystalViewer.Load, MyBase.Load
Dim rpt As New CrystalReport1()
Dim tbCurrent As CrystalDecisions.CrystalReports.Engine.Table
Dim tliCurrent As CrystalDecisions.Shared.TableLogOnInfo

For Each tbCurrent In rpt.Database.Tables
tliCurrent = tbCurrent.LogOnInfo
With tliCurrent.ConnectionInfo
.ServerName = " "
.UserID = " "
.Password = " "
.DatabaseName = " "
End With
tbCurrent.ApplyLogOnInfo(tliCurrent)
Next tbCurrent

CrystalReportViewer.ReportSource = rpt
CrystalReportViewer.Visible = True
CrystalReportViewer.Zoom(100)
CrystalReportViewer.RefreshReport()
end sub
 
Is there security on this database? You aren't providing any login information.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Tips and Tricks / Guide to Crystal in VB
- tek@kenhamady.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top