ODBC connection

S

SHIPP

I have a very long procedure that I usually run overnight. About midway
through I am going out to a company server and retrieving some information.
It's at this time that it asks for a user name and password. Consequently I
have to finish running the procedure in the morning. What I am trying to do
is to preconnect to the server when I kick off the procedure. I have come up
with the following code:

Public Sub Preconnect()

Dim wrkRemote As Workspace
Dim dbRemote As Database
Dim strConnect As String
Dim strUserName As String
Dim strPassword As String

strUserName = "XXXXXXX"
strPassword = "XXXXXXX"

strConnect = "ODBC;DSN=DB2P;DBALIAS=DB2P;UID=" & strUserName
& ";PWD=" & strPassword & ";"
Set wrkRemote = DBEngine.Workspaces(0)
Set dbRemote = wrkRemote.OpenDatabase("ingres_in_item_tbl", False, False,
strConnect)

dbRemote.Close

End Sub


The subroutine errors out on

Set dbRemote = wrkRemote.OpenDatabase("ingres_in_item_tbl", False, False,
strConnect)

Any ideas would be appreciated. I am working with Access 97.
 
Top