Eric
Here's how you could do it (cross-posted answer here
http://www.msofficegurus.com/forum/forum_posts.asp?TID=17):
Dim adoCon As Object
Dim rsCommon As Object
Sub Variable()
strSQLServerName = "IP_address"
strSQLDBUserName = "Your_SQL_UserName"
strSQLDBPassword = "Your_SQL_Password"
strSQLDBName = "YOur_SQL_DBName"
strCon = "Server=" & strSQLServerName & ";User ID=" & strSQLDBUserName &
";Password=" & strSQLDBPassword & ";Database=" & strSQLDBName & ";"
Call openDatabase(strCon)
End Sub
Sub openDatabase(strCon)
strCon = "Provider=SQLOLEDB;Connection Timeout=90;" & strCon
Set adoCon = CreateObject("ADODB.Connection")
On Error Resume Next
adoCon.connectionstring = strCon
adoCon.Open
If Err.Number <> 0 Then MsgBox Err.Description, vbCritical
On Error GoTo 0
'Your recordset, so look for the fields you want using this rs object
Set rsCommon = CreateObject("ADODB.Recordset")
'do your thing with the rs here
Set rsCommon = Nothing
End Sub
Sub closeDatabase()
If adoCon Is Not Nothing Then
adoCon.Close
Set adoCon = Nothing
End If
End Sub
--
Robert
Author of RibbonX: Customizing the Office 2007 Ribbon:
LATEST INTERACTIVE TUTORIAL:
http://www.msofficegurus.com/videos/StepByStep_HT_Chart.asp
FORUM:
http://www.msofficegurus.com/forum/