Changing Access mdb location in run time 
Author Message
 Changing Access mdb location in run time

Hi:
      I have a Crystal Report ( V 4.6.1) designed based on Acess mdb
file. I wondered if there is a way I can change the location of the mdb
file using VB  in runtime?  I noticed that Crystal Report Activex
Control has datafiles property, but that's only for dbf file.

Any suggestions will be appreciated
Brian Fan



Wed, 03 Jul 2002 03:00:00 GMT  
 Changing Access mdb location in run time
Hi

It's not exactly what you want, but think about !

Crystal has at menu options:  Database / Set Locations. There, you can set
all tables to the
the option "Same as Report"

Now you can put your .mdb file at any directory but putting together your
.rpt file with it.

This is my suggetion

Regards

Rui Torres


Quote:
>Hi:
>      I have a Crystal report ( V 4.6.1) designed based on Acess mdb
>file. I wondered if there is a way I can change the location of the mdb
>file using VB  in runtime?  I noticed that Crystal Report Activex
>Control has datafiles property, but that's only for dbf file.

>Any suggestions will be appreciated
>Brian Fan



Thu, 04 Jul 2002 03:00:00 GMT  
 Changing Access mdb location in run time
Hi Brian,

Maybe this example from my code will help.

Private Sub Form_Load()

    On Error GoTo ErrLocal

    LoadInit

    DataEnvironment1.Connections("Template").ConnectionString = strConnect
    DataEnvironment1.Connections("Template").Open
    DataEnvironment1.Q_Process_Account

    Report.Database.SetDataSource DataEnvironment1.rsQ_Process_Account
    Report.ReadRecords
    DoEvents

    CRViewer1.ReportSource = Report
    CRViewer1.ViewReport
    DoEvents

    CRViewer1.Refresh

    Exit Sub

ErrLocal:
    ErrorHandler
    Resume Next

End Sub

Quote:

>Hi:
>      I have a Crystal report ( V 4.6.1) designed based on Acess mdb
>file. I wondered if there is a way I can change the location of the mdb
>file using VB  in runtime?  I noticed that Crystal Report Activex
>Control has datafiles property, but that's only for dbf file.

>Any suggestions will be appreciated
>Brian Fan



Thu, 04 Jul 2002 03:00:00 GMT  
 Changing Access mdb location in run time
Brian,

    Isn't 4.6.1 the one that is bundled with VB?  I have 7.0 now, but
started with the one that was bundled with VB.  I use the following code to
change the database at runtime:

Dim intFiles as Integer, HOMEDB as String

HOMEDB = "C:\PathToMDBFile.mdb"

With CR1
    .ReportFileName = App.Path & "\" & Report & ".rpt"
    intFiles = .RetrieveDataFiles

    For intCounter = 0 To intFiles - 1
        .DataFiles(intCounter) = HOMEDB
    Next
    .Action = 1
End With

The only problem with this approach is that it doesn't work with Sub
Reports.  At least I don't think so which is why I posted a thread in this
NG asking about it.  If you're just using a standard report, this works, at
least in V 7.0

Good Luck

Lee


Quote:
> Hi:
>       I have a Crystal report ( V 4.6.1) designed based on Acess mdb
> file. I wondered if there is a way I can change the location of the mdb
> file using VB  in runtime?  I noticed that Crystal Report Activex
> Control has datafiles property, but that's only for dbf file.

> Any suggestions will be appreciated
> Brian Fan



Thu, 04 Jul 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Run Time Change of DB Location, Setting Passwords, and Rpt Location

2. Change MS Access MDB location

3. How to change Database location at run time

4. CR9 does not change table location at run time

5. Changing database location at run-time

6. Changing database location at run time

7. Change Database Location at run-time

8. Change TTX location at Run-Time - Please Help....

9. Changing Database\Table locations at run-time from VB6

10. ADO Data Control - Design Time/Run Time database locations

11. Change the location of the .mdb file ???

12. Changing Access report objects at run time.

 

 
Powered by phpBB® Forum Software