Solved

Data Environment and connection string

Posted on 2002-03-10
12
201 Views
Last Modified: 2010-05-18
Hi All!

I need to dynamically set the connection string of the Connection object in the data environment.  I've tried several ways, none of which worked.  Can anyone tell me where to set the string and how to set up the connection object properties in the DE so that it will take any connection string?

My attempt:

Public Function PrintCheckIn(ByVal iDrvrID As Integer, ByVal sBeginDate As String, _
                             ByVal sEndDate As String, ByVal sTitle As String)
    'Print the Check-In Report
    Dim ODE     As deAccReports
    Dim myRpt   As rptCheckIn
   
    On Error Resume Next
   
    Set ODE = New deAccReports
    Set myRpt = New rptCheckIn

    ODE.cnAccess.ConnectionString = App.Path & "\MyDatabase.mdb"
    ODE.cmCheckIn_Grouping iDrvrID, sBeginDate, sEndDate
   
    myRpt.Sections("Section4").Controls.Item(4).Caption = sBeginDate & " to " & sEndDate
    myRpt.Sections("Section2").Controls.Item(12).Caption = sTitle
   
    myRpt.Refresh
   
    If myRpt.Visible = False Then myRpt.Show

End Function

Thanks!
Alice
0
Comment
Question by:alicelknight
  • 6
  • 6
12 Comments
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 6855395
You can set it into the "Private Sub DataEnvironment_Initialize()" event
0
 

Author Comment

by:alicelknight
ID: 6856553
emoreau:  Thanks!  Let me check it out tonight.  I didn't try that.

Alice
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 6869349
any progress?
0
 

Author Comment

by:alicelknight
ID: 6870057
emoreau:  No, seems not to work.  I get the .Jet Dialog box opening up for the datasource and the connectionstring, etc......  any suggestions?

Alice
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 6870074
1. add a standard module to your project
2. in that module add a "public sub main" procedure.
3. add code to this procedure to change your connection string and open your DE.
4. from the project properties, modify the startup object to "sub main"
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 6870080
and your connection string is not valid! where is the provider and ... all the others parameters?

see http://www.able-consulting.com/ADO_Conn.htm#OLEDBProviderForMicrosoftJet for the complete syntax.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:alicelknight
ID: 6872365
emoreau:  I changed the connection string and it still doesn't work.  Nothing I do seems to change the string that's already entered in the path of the connection object in the DE.

Alice
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 6874174
zip your project and send it to emoreau99@hotmail.com
0
 

Author Comment

by:alicelknight
ID: 6878677
emoreau:

Thanks a bunch!  It's on its way

ALice
0
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 200 total points
ID: 6879701
it's back to you! simply change the mdb from your connection string to MDE.
0
 

Author Comment

by:alicelknight
ID: 6881758
emoreau:  Actually, I sent the project with an .mde and not the .mdb.  My app runs with the .mdb.  But yours works! :)  The only difference I see is that you're not using the class.  And making sure the report is closed before opening.  I'm sure I can get mine to work now.  thanks a whole bunch, now my vacation will be that much nicer! :)
Alice
0
 

Author Comment

by:alicelknight
ID: 6884312
emoreau:  The problem...?  Once I put the DataEnvironment connection object and the 2 reports into the project that I am calling it from it works.  But it will not work leaving it in the ActiveX.exe.  Thanks so much for your help!

Alice
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now