Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Flexibility

Status
Not open for further replies.

Zbob

MIS
Apr 25, 2002
94
US
I am learning flexibility and need to connect to a access 2000 db using ADO.

 

Create a public variable called Tablesdd, example:

Public conTablesDb as New ADO.Connection

Add this function to your code module:

Function bOpenTablesDatabase(ByVal strDbname As String) as_ Boolean

On Error GoTo bOpenTablesDBConnection_err

Set conTablesDB = Nothing
conTablesDB.Open_ ("Provider=Microsoft.jet.OLEDB.4.0;Data_ Source="+strDBname)


'connection is open, return true

bOpenTablesDatabase = True

Exit Function

'***********************
bOpenTablesDBConnection_err:
'***********************
'connection failed, return false

MsgBox Str$(Err) + Error$

bOpenTablesDatabase = False


End Function

In your code, pass the path to the function to open the ADO connection, example

if bOpenTablesDatabase("\\Accntg\programmers\bonus.mdb")_ then
'do your thing
else
Msgbox "Unable to open a connection to Accounting_ Server, call a nerd for help"

End if

Hope this helps
Kirk



 
Typo in first line, should have read
"Create a public variable called conTablesdb"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top