Solved

how do i get it to print ?

Posted on 2000-03-21
9
151 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
ID: 2640275
create another table\query containing only the fields you need to display.
0
 

Author Comment

by:JOHNHO
ID: 2640377
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
ID: 2640416
can u give me the other solutions ?

if i do that, i will still get the same the same results.
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 1

Expert Comment

by:jonder
ID: 2640831
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
 
LVL 1

Expert Comment

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

Accepted Solution

by:
Voodooman earned 100 total points
ID: 2644019
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
ID: 2644839
fails .

pls be more specific.


increase points if success.

thanks
0
 
LVL 5

Expert Comment

by:Voodooman
ID: 2648371
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
ID: 2679459
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

777 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