|
-
Mar 8th, 2006, 07:43 AM
#1
Thread Starter
Member
Change CR Field Value From VB6
I have created a report and am looking to change a value of one of the fields through VB6...can this be done?
I was looking to do something like this (I know this is wrong but something along these lines) the field in CR is called for example: USERID
Report.Field.USERID = "WhateverValue"
I know this is wrong but do you get what I mean? If not please ask and I will try and explain in more depth... If it can be done what would the code be?
Thanks
-
Mar 8th, 2006, 10:58 AM
#2
Re: Change CR Field Value From VB6
Which Version, Edition and Licensing of CR do you have? What type of object is the UserId field? Database, Textbox, Formula, Special Field?
-
Mar 9th, 2006, 03:38 AM
#3
Thread Starter
Member
Re: Change CR Field Value From VB6
I am using version 9 of CR
UserID is a Textbox
-
Mar 9th, 2006, 08:29 AM
#4
Re: Change CR Field Value From VB6
You would probably want to use a Parameter field in the report. That way you can set the parameter value from VB when you process the report.
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Mar 9th, 2006, 01:34 PM
#5
Re: Change CR Field Value From VB6
All report objects can be accessed via VB if you have a developer edition. Add a refererence to the Crystal Reports ActiveX Designer Runtime Library to your project.
This VB6 code is for Crystal 8.5 but it should be similar for version 9.
VB Code:
Dim objCrystal As New CRAXDRT.Application
Dim objReport as CRAXDRT.Report
Dim objTextBox as CRAXDRT.TextObject
Set objReport = objCrystal.OpenReport(ReportPath, 0)
Set objTextBox = objReport.Sections("Section1").ReportObjects("Text6")
objTextBox.SetText "User Id"
'code to view/print report
You will need to find the correct Section name and TextObject name used by Crystal.
-
Mar 10th, 2006, 06:28 AM
#6
Thread Starter
Member
Re: Change CR Field Value From VB6
Could you explain what is entered into the ("Section1") part?
I am a little confused?!
-
Apr 1st, 2008, 12:26 PM
#7
Frenzied Member
Re: Change CR Field Value From VB6
Hi Brucevde:
Do you know the way to change a name field create in a .ttx file?
It's the same way that you present in your post?
Thanks
-
Apr 1st, 2008, 12:44 PM
#8
Re: Change CR Field Value From VB6
Sorry, I am not sure exactly what you are asking.
Assume the .ttx file contains
Code:
Id Long
CustomerName String 30
Are you asking how to change the above ttx file to something like the following and then update the report file (.rpt) to change all occurrances of Id to CustomerId.
Code:
CustomerId Long
CustomerName String 30
-
Apr 1st, 2008, 12:54 PM
#9
Frenzied Member
Re: Change CR Field Value From VB6
-
Apr 2nd, 2008, 04:03 AM
#10
Frenzied Member
Re: Change CR Field Value From VB6
Could you explain what is entered into the ("Section1") part?
Bruce's code can also be written like this
Report.Sections(1).ReportObjects(1).SetText "YOUR TEXT"
Where
- .Sections(1) is the section (Report Header, Page Header, Details etc) where the Textbox resides
- .ReportObjects(1) is item number of the object (within the section) you want to manipulate. In present case Textbox
-
Apr 2nd, 2008, 06:05 PM
#11
Frenzied Member
Re: Change CR Field Value From VB6
Hi:
Thanks for your answear,but I have a few doubts:
1 - The code you present is valid for Text box create in CR right?Wich way I can see the number of the object?
When you tell that .Sections(1) is the section (Report Header, Page Header, Details etc),I presume if the section is details than .sections(3)...thats it?
2 - And for database fields?It's the same sintax?Because I want rename a database field in my report before sort a recordset
Thanks
-
Apr 3rd, 2008, 12:11 AM
#12
Frenzied Member
Re: Change CR Field Value From VB6
When you tell that .Sections(1) is the section (Report Header, Page Header, Details etc),I presume if the section is details than .sections(3)...thats it?
Not necessarily.. You might have seen using the Section Expert you can insert more sections
-
Apr 3rd, 2008, 03:16 AM
#13
Frenzied Member
Re: Change CR Field Value From VB6
Ok...That's correct about .Sections(x)
I had try the code and work with text box...But with the database fields not work...do you know the syntax for those fields?
-
Apr 3rd, 2008, 04:03 AM
#14
Frenzied Member
Re: Change CR Field Value From VB6
you want to rename a dbfield in report? what do you gain by that...
If absolutely necessary I would recommend you create view/Query with the desired field names and link it to the report instead.
-
Apr 3rd, 2008, 06:59 AM
#15
Frenzied Member
Re: Change CR Field Value From VB6
I work with .ttx files,and I don't have any link with database...My problem is that I had create a field(in .ttx file) named "Registo",but I need chance this name sometimes for "RegistoCM" other times to "RegistoDE"...If I do not chance the name I can't see the records in my report...That's because I need chance the name in this field...
-
Apr 3rd, 2008, 07:03 AM
#16
Frenzied Member
Re: Change CR Field Value From VB6
I don't have any knowledge of these .ttx files. Anyway try renaming by the above methods and let us know the results. Remember each field placed in the report is an item withing the section...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|