Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

how do i get it to print ?

Posted on 2000-03-21
9
152 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

839 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