VPN Connection

J

JimBob

I have developed an Excel report using ADO database connection - thanks to
the help from you good folks on this forum - but most of my users are remote,
travelling to client sites - wondering if there is a way I can test for a
conneciton to the network/datasource and initiate a VPN connection if
required.

Any suggestions?

Thanks,

Jim
 
J

Jim Thomlinson

I test my connection with the following code... Note that m_cDSN, LOGIN_NAME
and LOGIN_PASSWORD are global variables...

Public Function TestConnection() As Boolean
Dim cn As ADODB.Connection

TestConnection = True
Set cn = New ADODB.Connection
On Error GoTo Errorhandler
cn.Open "DSN=" & m_cDSN & ";Uid=" & LOGIN_NAME & ";Pwd=" &
LOGIN_PASSWORD & ";"
cn.Close
Set cn = Nothing
Exit Function
Errorhandler:
TestConnection = False
Set cn = Nothing
End Function

You use it like this...

if TestConnection = false then
msgbox "Connect to VPN and try again"
else
'run the query
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