Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changed DB Location - still needs mapping?

Status
Not open for further replies.

princessjen

Programmer
Mar 23, 2001
2
US
I wrote the .rpt using one SQL view, and now I want to change it to another SQL view (on another server) with identical fields. I run through Database -> Set Location and set it to the new db. If the output fields are named the same, why am I being asked to map the fields manually? I thought it was because some of the fields were different data types (I have a lot of nulls in the new view) but they often show up even if the "Match TYpe" box is checked.

Help would be greatly appreciated -- I am converting 50-100 reports this way.
 
Change of datatype is the reason that you need to map fields. Checking "Match type" let CR shows you which fields you have same datatype and which are not. For example, orderid is int in the old table, and orderid is varchar in the new table. When you check "Match Type", orderid will not be shown because their datatype is different. If you un-check it, orderid will show up.

Actually, you need to map the fields one-by-one. Did you see "Map" button in "Map Fields" dialog box? Referring to my previous example, you need to select orderid in both "Report fields" and "Database provided fields", press "Map" button. Orderid, then will drop to "Mapped fields".

I am using CR8, I am not sure if this is same as yours. You may try it out.
 
Changing Database Location during Runtime

------------------------------------------------------------------
I am suprised to see a lot of people with this problem. I thought the Crystal people
are not even bothered with this problem or making it simpler for programmers.
However, i encounterred the same problem when i convert my .RPT files to using
Crstal report viewer control.

Im in love with this control but the problem of "..cannot open file" when changing the
database location during runtime nearly put me off. However, with the help of inspiration of
the Holy Spirit, i scaled through it.

Are you ready to go with me? Here lets go.
Please i am still using DAO data access because my program works very fine and i dont
have the
time to convert it to ADO data access.

If it works for your ADO data access please post your own contribution to me
--------------------------------------------------------------------
1. Add the Crysal Viewer control(.ocx) to your form - Form1.
2. Create your report with using the Crystal Report Designer component - CrystalReport1
3. Put the following code in the Form1 module

option Explicit
Dim oDB As New CRAXDRT.Application
Dim oTb As CRAXDRT.DatabaseTable
Dim Report As New CrystalReport1

Public strFormula as String 'Selectio formula property

Private Sub Form_Load()
Screen.MousePointer = vbHourglass

On Error GoTo HandleError

For Each oTb In Report.Database.Tables
oTb.Location = gdb.Name
'
'Note gdb is my database object
'gdb.Name returns the path name of the database
'e.g c:\VBProject\Stock.mdb
Next oTb


With Report
.DiscardSavedData 'refresh report data
.ConvertNullFieldToDefault = True
.RecordSelectionFormula = strFormula 'my selection formula like "{Stock.Class}='LS'"

CRViewer1.ReportSource = Report
CRViewer1.ViewReport
End With
End Sub


Run your code and change the database location and rerun it again.

Please post me if you encounter any error

Thanks.

Tunde Aransiola
tundearansiola@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top