|
-
Jan 10th, 2007, 07:18 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Data Environment connection problem
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:
Private Sub cmdPrint_Click()
Dim strDate As String
Dim strSQL As String
' Make sure the connection isn't left open from last printing
If dePrint.rsPrint.State = adStateOpen Then
dePrint.rsPrint.Close
End If
' If I leave out these next 4 lines it works fine
dePrint.con1.Provider = "Microsoft.Jet.OLEDB.4.0"
dePrint.con1.CursorLocation = adUseClient
dePrint.con1.Properties("Data Source") = App.Path & "\EmpLic.mdb"
dePrint.con1.Open
' Get date information. This is what you guys helped me with and it works fine.
strDate = "#" & Format(Now, "mm/dd/yyyy") & "#"
strSQL = "SELECT * FROM Licenses WHERE DateDiff(" _
& Chr(34) & "d" & Chr(34) _
& ", " & strDate & ", [LicenseExpires]) <= 30 ORDER BY EmpName"
' Open the report with the selected info. Works fine if left to default.
dePrint.rsPrint.Open strSQL
datPrint.WindowState = vbMaximized
datPrint.Show
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|