Adding new report fields

hog

Well-known member
Joined
Mar 17, 2003
Messages
984
Location
UK
I have created a report based on a dataset in order to get the underlying report to up and running. The report then uses a dynamic dataset at runtime to populate its fields based on user selection.

I now need to add other fields but I see that the fields I can choose from in design mode are restricted to those in the original dataset. If I update the report to point to a modified version of the original dataset I loose all formatting on the report.

Is there a way to add fields at will without buggering the whle report? This is very staright forward in Access report writer but cannot work out how to do it in Crystal reports?
 
Sorted:

Field Explorer -> Database Fields -> Right Click table -> Verify Database
 
I have tried that but the database fields doesnt get updated or refreshed.

Heres what I did at the begining. Because I want to compare the database field SSN to a run time variable intSSN, I decided to fill my dataset at run time instead of using the wizard. So the next problem for me is how do I bring those fields from the select query to the Database Field tree so I can design my report. I have no clue so there is a person on the net told me that I can do this:

usrDataset.WriteXmlSchema("C:\temp\rprtSchema.xml")

in my code and run the application to write the file. Then I can import that xml schema to the Database Field tree so I can design my report.

If I know a better way to do what I wanted to do, I would but Im new to VB.NET.

Chong
 
I do it another way. I have a dataset and dataadapter on my report form which I use in design time. I modify the select query to bring in the required new fields, veryify the database and the fields are there.
 
Hog, would you be kind enough to show me how to do it in your way? Or perhaps show me a link to do it in another way that would give me an update of the database fields whenever I changed my SQL query.

Thank you very much!

Chong
 
In your report designer view, click on Field Explorer, right click on Database then select verify database. If you have made changes it will tell you the database is out of sync and allows you to resysnc it. If you make changes then do this but it says it cant find any changes then close .NET down and start it again and it will detect the changes. Works for me :-)
 
Thanks for helping me out. Im greatly appreciated.

I have tried the update like you suggested and it returns The Database is up to date but it never shows the new fields in the new table that I added to my SQL query. I wonder if this update will actually go through my SQL query and know that Ive added a new table and show the fields in that table in the Database Field tree.

Chong
:confused:
 
OK, in my case it works as I modify the SQL in the dataadapter to pull in the new fields. I generate the dataset then report design view, onto field explorer, verify database and it works?
 
But do you use the wizard to configure your DataAdapter? For mine, the DataAdapter are created and the DataSet are filled at run time.

Chong
 
OK, not sure if this is the most effcient but this is how I got it to work as cystal is different than Access reporting.

In report design I have a dataadapter and dataset with the required fields for the report. I use this to design the report to start with.

When I use the report at runtime I point the reports recordsource to a dynamic dataset which has the same fields as the one used fr design time. When I am happy with the report the design time one is deleted as it is no longer needed.

During development if I realise the dynamic dataset requires additional fields that will need to be on the report, I modify the design time one to gain access to the field objects to place on the form.

Like I say not the most effcicient but it works for me and I have not had any info yet on a better way to do it?
 
Yeah, I see your method. It works; however, will this method work? Write the XML schema to a file

usrDataset.WriteXmlSchema("C:\temp\rprtSchema3.xml")

and then copy whatever code is new, which is the latest table fields, into xml schema I used to generate the report at the first place.

Chong
 
The way to find out is to try it. I havent directly modified XML yet so have no knowledge of doing it that way, although I cant see why it wouldnt?
 
Back
Top