Hey guys,
I am using the DataEnvironment and DataReport to show a simple little printout.

If I use the database connection wizard for the DataEnvironment, it connects just fine. But the problem is that when run from another system, the file path is different.

I tried doing App.path method, but that didnt' work so I figured I would have to code the connection.

This is the same bit of code you guys helped me with last week. Here is what I've got.

I have a DataEnvironment called dePrint
Inside that, I have a DEConnection called con1
Inside that, I have a DECommand called Print

My DataReport is called datPrint
- The DataMember property is set to Print
- The DataSource Property is set to dePrint

VB Code:
  1. Private Sub cmdPrint_Click()
  2.  
  3.     Dim strDate As String
  4.     Dim strSQL As String
  5.  
  6. '   Make sure the connection isn't left open from last printing
  7.  
  8.     If dePrint.rsPrint.State = adStateOpen Then
  9.         dePrint.rsPrint.Close
  10.     End If
  11.  
  12. '   If I leave out these next 4 lines it works fine
  13.  
  14.     dePrint.con1.Provider = "Microsoft.Jet.OLEDB.4.0"
  15.     dePrint.con1.CursorLocation = adUseClient
  16.     dePrint.con1.Properties("Data Source") = App.Path & "\EmpLic.mdb"
  17.     dePrint.con1.Open
  18.    
  19. '   Get date information. This is what you guys helped me with and it works fine.
  20.  
  21.     strDate = "#" & Format(Now, "mm/dd/yyyy") & "#"
  22.     strSQL = "SELECT * FROM Licenses WHERE DateDiff(" _
  23.        & Chr(34) & "d" & Chr(34) _
  24.        & ", " & strDate & ", [LicenseExpires]) <= 30 ORDER BY EmpName"
  25.  
  26.    
  27. '   Open the report with the selected info. Works fine if left to default.    
  28.  
  29.     dePrint.rsPrint.Open strSQL
  30.     datPrint.WindowState = vbMaximized
  31.     datPrint.Show
  32.    
  33.    
  34. End Sub

Under the DataEnvironment, I have the connection (con1). If I use the built-in wizard to select the database, it works fine, but I need it to be App.Path so it can work on any system.

Any ideas where I screwed up or what I'm forgetting?

Thanks