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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CR8 - Unable to change location of database file or tablename

Status
Not open for further replies.

meenakshikalera

Programmer
Jun 23, 2004
8
0
0
US
Hi!
I have just started using Crystal Reports 8 with VB 6...I have some Report templates already made in VB6...while making those reports tables were created as follows:

Server Type: ODBC MS Access 97 Database
Server Name: MS Access 97 Database
Database: V:\meenakshi\system1.mdb (some mapped drive from another computer)
User ID: Admin

Now say, i want to run this project on the client side...obviously in that case, the server name (here it is access so may not change, but in the case of ms sql server 2000, the server name may change), database would change....
i want all my templates to still run....how is that possible...i have written the following piece of code, but it is still not working...i have searched lots on the forums etc. but i am sure i am missing somethind very minute somewhere....pasted below is my code:
----------------------------------------------------
Dim crxApplication As New CRAXDRT.Application
Public Report As CRAXDRT.Report
Dim crxDatabaseTable As CRAXDRT.DatabaseTable
Dim crxParameterField As CRAXDRT.ParameterFieldDefinition
Dim crxFormulaField As CRAXDRT.FormulaFieldDefinition
Dim cTable As CRAXDRT.DatabaseTable

Dim myServerName As String
Dim myDatabaseName As String
Dim myTableName As String

Private Sub Form_Load()

' this rptReport1 report is prepared using EMPLOYEE table in the System1.mdb and i want to change it to use the CUSTOMER table in Sytem1.mdb at runtime or i want to change the location of my database file System1.mdb from V:\meenakshi to some other place

Set Report = crxApplication.OpenReport ("V:\meenakshi_Conversion\rptReport1.rpt", 1)

frmViewer.Show vbModal

For Each cTable In Report.Database.Tables

myServerName = cTable.LogOnServerName
myDatabaseName = cTable.LogOnDatabaseName
myTableName = cTable.Name
myLocation = cTable.Location

' i am just printing the servername, database name and tablename that r currently used in the rpt
Text1.Text = myServerName
Text1.Refresh
Text2.Text = myDatabaseName
Text2.Refresh
Text3.Text = myTableName
Text3.Refresh

'now i want to change the table name to CUSTOMER .... rest everything remains same ...or may be i move my database file, that is System1.mdb somwhere else and try to ask the report to use this database location now... in that case, table name remains same but database name changes to reflect the new location
cTable.Name = "EMPLOYEE"
cTable.Location = cTable.Name
cTable.SetLogOnInfo myServerName, myDatabaseName, "admin", ""
myServerName = cTable.LogOnServerName
myDatabaseName = cTable.LogOnDatabaseName



' i am just printing the servername, database name and tablename that r now used in the rpt
myTableName = cTable.Name
Text4.Text = myServerName
Text4.Refresh
Text5.Text = myDatabaseName
Text5.Refresh
Text6.Text = myTableName
Text6.Refresh


Next

frmViewer.Show vbModal
End Sub
--------------------------------------------------
thanks,
regards,
meenakshi
 
For this type of connection to an Access db, you need to use the SetTableLocation method:
[tt]
cTable.SetTableLocation "C:\Path\system1.mdb", "EMPLOYEE", ""
[/tt]
SetTableLocation Method (DatabaseTable Object)

The SetTableLocation method is used to set the DatabaseTable location, sublocation, and connect buffer string.

Syntax

Sub SetTableLocation ( pLocation As String, pSubLocation As String,
pConnectBufferSting As String )

Parameters

plocation - Specifies the location of the database table (file path and name.ext).
pSubLocation - Specifies the sublocation of the database table.
pConnectBufferSting - Specifies the connection buffer string.

Remarks
For example:
object.SetTableLocation "xtreme.mdb", "Customer", ""

-dave
 
Hi Vidru!

its still not working....i had used cTable.SetTableLocation method earlier too....but the last parameter was not correct...i tried using it the way u mentioned now...but no luck yet....

pls lemme know a way out.

thanks,
meenakshi
 
Are the field names and datatypes exactly the same in both tables?

... but the last parameter was not correct...
What parameters did you try to send?

-dave
 
hi!

by saying the last parameter was not correct, i meant tht earlier on i had used SetTableLocation but some parameter was not correct, but yesterday after reading ur message i changed it again using ur hint...it still did not work...

yes the database remains the same....everything is same except that i have changed the location of the database file, System1.mdb from V:\meenakshi to say C:\meenakshi....so basically i am trying to access the same table "Employee" but now from C:\ instead of V:
my goal after this is to do the same thing for MS SQL Server 2000....so if this works for access...i believe it shud work for tht too...wht do u say?

do u want me to send u a zip file consisting of my 2 forms and my database and report...so tht u can try n debug it if u have some time....

lemme know...
thanks for all ur help..
regards,
meenakshi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top