Change

  • Thread starter Simon Niederberger
  • Start date
S

Simon Niederberger

Hi all

I have the code posted below in the startup routine of my ADP (Access 2000 +
MSDE). When no initial connection is found and the OLE Connection Dialog
comes up, the connection might afterwards be established, but the new
connection property is not saved to the ADP. Thus, when I close and reopen
the ADP, the old connection string is still in there.

Shouldn't Application.CurrentProject.OpenConnection set the
BaseConnectionString?


Thanks
Simon

If CurrentProject.IsConnected Then
DoCmd.OpenForm "fMainForm"
Else

Set lnk = New MSDASC.DataLinks
Set oConn = New ADODB.Connection

oConn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security
Info=False;" & _
"Data Source=localhost;User ID=sa;Initial Catalog=LaTrack;"

good = lnk.PromptEdit(oConn)
oConn.ConnectionTimeout = 5
On Error Resume Next
oConn.Open
On Error GoTo 0

'Set oConn = lnk.PromptNew
If oConn.State = adStateOpen Then
connStr = oConn.ConnectionString
oConn.Close
Set oConn = Nothing
Set lnk = Nothing
'Application.CurrentProject.CloseConnection
Application.CurrentProject.OpenConnection connStr
Else
DoCmd.Quit
End If

End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top