473,320 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to change query table name at run time in crystal report

irfanafzal
Hello
I have saved query in MS Access
"SELECT ID ,Name, Address from Data2001"
I am using this query in Crystal report
My question is this can I change table name in this query "DATA2001" to "DATA2002" at runtime
Thanks .
May 14 '10 #1

✓ answered by QVeen72

Hi,

CheckThis

Regards
Veena

10 4959
QVeen72
1,445 Expert 1GB
Hi,

What is your version of CR..?
May 14 '10 #2
Sir i have CR 9
May 15 '10 #3
QVeen72
1,445 Expert 1GB
Hi,

After Opening report (CrRep), write this code:

Expand|Select|Wrap|Line Numbers
  1. Dim crDB As CRAXDRT.Database
  2. Dim crTab As CRAXDRT.DatabaseTable
  3. ' Open Cr appl and report here..
  4. Set CrRep = CrApp.OpenReport("C:\MyReport.rpt")
  5. Set crDB = CrRep.Database
  6. For Each CrTab In CrDB.Tables
  7.     crTab.Location = "C:\MyDB.mdb"
  8. Next 
  9. ' Code to show the report in cr viewer here...
  10.  
Regards
Veena
May 17 '10 #4
VERY VERY THANKS FOR REPLY
I THINK I HAVE NOT GIVE U COMPLETE DETAILS.

I HAVE SAVED QUERY (name of the query is "Details") IN ACCESS 2007.
this query have the text "SELECT ID ,Name, Address from Data2001"
(in this query there are also many other fields")
now i want to replace the table name " Data2001 ' to "Data2002" in query text .

i have 10 tables names Data2001,Data2002..... and so on. all the tables have same structure
(I want to change Table Name in Query Text Not table )
i hope now you have understand my question waht i want.
i want to use same query for all tables.

is it possible ?
May 17 '10 #5
QVeen72
1,445 Expert 1GB
Hi,

In that case simply Drop The QueryDef, and create a new with required table name... keep query name same

Regards
Veena
May 17 '10 #6
plz tell me how?
how can i use queryDef.
i am using ADO.
with best regards
May 17 '10 #7
QVeen72
1,445 Expert 1GB
Hi,

CheckThis

Regards
Veena
May 18 '10 #8
Hi
Thanks veena g. i think i have got my answer.

Dim cat As New ADOX.Catalog
Dim cmd As New ADODB.Command
Dim sqltext As String
' create the sqltext as in the example above

Set cat.ActiveConnection = CurrentProject.Connection
cmd.CommandText sqltext
Cat.Views.Append "My_Query", cmd

one thing more can i do the same thing without using ADOX.Catalog.
(I am using VB6) is it possible ?.Because some on told me it Create problems.(ADOX.Catalog)

Thanks Again
with best regards
May 18 '10 #9
QVeen72
1,445 Expert 1GB
What kind of problems...?
May 18 '10 #10
i dont know what type of problems creates this ADOX.Catalog'
some one told me that there are problems.(like some time u can not create quires or invalid connection like this).
i did not use this.
now i will use this for my project

thanks for helping me
with best regards
May 18 '10 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: cj | last post by:
Has anyone come across the following error in running a Crystal Report in ASP.NET using the Crystal Reports Web Viewer control... CrystalDecisions.CrystalReports.Engine.InvalidArgumentException:...
4
by: Grant Stanley | last post by:
I'm developing an application in VS.Net 2003 using C#, which uses Crystal Reports. When creating each report, crystal asks where the database to use is, so I specify our SQL server using the ADO...
6
by: thomas.jacobs | last post by:
I have reports formated and now need to use that format on another table name with the same field names as formated in the report. I belive it is in the properties but I can't seem to find it....
0
by: Ray | last post by:
Dear all, Now I am using the report document in vb.net to call the crystal report and I will set the database information in the report document. The code is as follow: ......
6
by: Agnes | last post by:
Please help, i had completed over 30-50 reports, now. our client insist to change the database name. anyshorcut that I can change the database name in the report without re-write all of them ??...
0
by: Ray | last post by:
Hi, I have deployed a program with crystal report called in three client's PC. Two of the clients can preview the report successfully. However, the remaining clients has error occured while...
1
by: Learner | last post by:
Hi there, I am a first time crystal user. We have a need to create a crystal report from my web form. Is there a blog or an article that explains step by step how do i create a report? Please...
1
by: Frank Teunen | last post by:
Dear reader, I'm having a problem linking a dataset to a crystal report. I'm using next code. In between I explain my problem 'This code is to fill a dataset with the result of a stored...
7
by: bluenewport | last post by:
I union several tables by query. And I plan to use table name to identify data source. Any one can help? Thnaks
2
by: Joey | last post by:
I am querying a DataSet with LINQ. I am running into a problem when trying to construct my query because in the "from" clause I do not know the table name (range variable) until runtime. Possible...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.