Solved

how do i get it to print ?

Posted on 2000-03-21
9
149 Views
Last Modified: 2012-05-04
like this, i has 1 crystal report and 1 data control and 1 123.rpt file.

and i using the below code .

CR1.ReportFileName = "C:\ZERO\123.RPT"
CR1.PrintFileName = "C:\ZERO\123..RPT"
CR1.RetrieveDataFiles
CR1.Action = True

that will print all the data in that database.

but what i want is it just print the data that i just selected by using the below code

 cr1.SQLQuery = "SELECT * FROM comp " & strWhere1 & strwhere2 & strWhere3 & strwhere4 _
  & strWhere5 & strwhere6 & strWhere7 & strwhere8 & strwhere9

CR1.ReportFileName = "C:\ZERO\123.RPT"
CR1.PrintFileName = "C:\ZERO\123.RPT"
CR1.RetrieveDataFiles
CR1.Action = True

but y i didnt print the data that i select by using the sql statement ?

i hope u understand n find a way to help me .


thanks

0
Comment
Question by:JOHNHO
9 Comments
 
LVL 5

Expert Comment

by:AnswerTheMan
Comment Utility
create another table\query containing only the fields you need to display.
0
 

Author Comment

by:JOHNHO
Comment Utility
can u give me the other solutions ?

if i do that, i will still get the same the same results.
0
 

Author Comment

by:JOHNHO
Comment Utility
can u give me the other solutions ?

if i do that, i will still get the same the same results.
0
 
LVL 1

Expert Comment

by:jonder
Comment Utility
cr1.SQLQuery = "SELECT * FROM comp " & strWhere1 & strwhere2 & strWhere3 & strwhere4 _
  & strWhere5 & strwhere6 & strWhere7 & strwhere8 & strwhere9

CR1.ReportFileName = "C:\ZERO\123.RPT"
CR1.PrintFileName = "C:\ZERO\123.RPT"
cr1.SQLQuery = "SELECT * FROM comp " & strWhere1 & strwhere2 & strWhere3 & strwhere4 _
  & strWhere5 & strwhere6 & strWhere7 & strwhere8 & strwhere9
CR1.RetrieveDataFiles
CR1.Action = True
CR1.REFRESH
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 1

Expert Comment

by:simonstre
Comment Utility
can u display what's in strWhere1, strWhereX ?
0
 
LVL 5

Accepted Solution

by:
Voodooman earned 100 total points
Comment Utility
You cant  change the query in Crytstal reports apart from the where clause.

Its in the documentation.

What you should be doing is changing the selection formula.


like this

MyReport.ReplaceSelcetionFormula=""

MYReport.ReplaceSelectionFormula ("{Q_ViewStockTransactions.Type} = 'Sale')

If you want to pass a variable

MyReport.ReplaceSelectionFormula ("{Q_ViewStockTransactions.Type} = '" & SelectOptions & "'")

Set up the selection formula that works in the designer and copy it is a good starting point.

This is absolutely the right way to do it.

Voodooman!
0
 

Author Comment

by:JOHNHO
Comment Utility
fails .

pls be more specific.


increase points if success.

thanks
0
 
LVL 5

Expert Comment

by:Voodooman
Comment Utility
From Voodooman

OK!

I assume you are using the Crystal Report Designer to design a report.

Design your report without any selection.

Now from the Report Menu choose Select Expert.

Select a field

Now Click Show Formula

Now you will see the formula building.

Now copy the formula by highlighting it and using Ctrl+C.

Example: {Label_Temp.Label} = "Voodoo"

Now remember to change the quotes like this so VB can use


Change to {Label_Temp.Label} = 'Voodoo'

Using the Code I have given You paste in the selection Criteria

MyReport.ReplaceSelectionFormula ("Put Your Selection Formula between these quotes")


To get something like this:
MyReport.ReplaceSelectionFormula ("{Label_Temp.Label} = 'Voodoo'")

When you have this working you can start to change the Select string with your variables.

Also always remember when you save your report in the designer to make sure that the 'Save Data with Report' is not selected.

Good Luck

Voodooman!!
0
 

Author Comment

by:JOHNHO
Comment Utility
sorry a lot to voodoman.
im a munch munch more stupid and not an easy understan person please forgive me.

can u explane it more details.

how about u do it for me.

i has 3 field .
which is computer type and id number and person incharge.

that 3 field include in abc.mdb databse.


so how do i ask it to show in crystal report the thing i had sort it.

pls show the full one because i just need to copy the formula only and show me where do i go and how do i get it.

for previous solution i just can go to select formula then dont know where to go.

pls help me and i will increase the points for u.


thanks a lot.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now