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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hello, On startup of my form run

Status
Not open for further replies.

boblovesyousomuch

Programmer
Dec 2, 2003
27
GB
Hello,

On startup of my form run Access 97 database I currently check that the linked tables i have to other databases connect successfully.

I also have a few tables that I link via a ODBC connection using a DSN called "CallDB". I has a username and password to access it.

What I want to do is to automatically connect to the tables in this database by supplying the username/password, if it doesn't connect properly an error message is caused.

I have seen some examples but can't seem to get what I want.

Thanks

Carl
 
here is a linking function I often use:



Private Sub LinkTable(s As String)
On Error GoTo whassup

'm_username and m_password are variables
'holding the obvious...

'next is actually all one line

DoCmd.TransferDatabase acLink,
"ODBC Database",
"ODBC;DSN=" & m_Connection
& ";UID=" & m_username &
";PWD=" & m_password,
acTable, s, s


'this commented line uses another function to check
'if the link worked - ie is the table now present?

'Call CheckTable(s)


Exit Sub
whassup:
MsgBox Err.Description
Resume Next
End Sub
 
Hi,

Thanks for that.

I have done this but get connection failed! Any ideas?

Code:
Function LinkTable()
    On Error GoTo whassup
    
    DoCmd.TransferDatabase acLink, "ODBC Database", "ODBC;DSN=CallDB;UID=userSukonik;PWD=sukonik", acTable, "dbo.d_input_map_define", "dbo_d_input_map_define"
    
      Exit Function
whassup:
      MsgBox Err.Description
      Resume Next
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top