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

Getting linked tables to remember password?

Status
Not open for further replies.

joebickley

Programmer
Aug 28, 2001
139
GB
Hi, I have the following code to reconnect all of the linked tables to an SQL server. Only thing is it does not remember the password next time the DB is opened. Any ideas?
Code:
Public Function LinktoSQL() As Boolean
Dim cODBCPATH As String
cODBCPATH = "ODBC;DRIVER=SQL Server;SERVER=solihullweb;UID=sa;PWD=soldata;DATABASE=RCS_data"


Dim db As DAO.Database
Dim i As Integer
Dim tdfNew As DAO.TableDef
Dim rec As DAO.Recordset
Dim tdfLinked As DAO.TableDef
Dim strtablename As String

On Error GoTo LinktoSQL_Err

Set db = CurrentDb()
Set rec = db.OpenRecordset("tblLinkedTables")
rec.MoveLast
rec.MoveFirst

For i = 1 To rec.RecordCount
   strtablename = rec.Fields(1).Value
   Set tdfNew = db.CreateTableDef(strtablename)
   tdfNew.SourceTableName = rec.Fields(1).Value
   tdfNew.Connect = cODBCPATH 'Constant ODBC Conn. string
   db.TableDefs.Append tdfNew
   rec.MoveNext
Next i
LinktoSQL_Exit:
    Set rec = Nothing
    Exit Function
LinktoSQL_Err:
    Select Case Err.Number
        Case 3010 'In case the linked table is there
            db.TableDefs.Delete strtablename
            db.TableDefs.Append tdfNew
            Resume Next
        Case Else
            MsgBox Err.Number & Err.Description
            LinktoSQL = False
    End Select
End Function

:) Joe Bickley
 
im not using a MDW at the moment this is just a test app at the moment. I t is more for my convinience than to use in the actual app
 
Hi again , try this solution.

After Update the User Name, you can Lookup the Password

Private Sub UserName AfterUpdate()
Dim varX as Variant

DLookup "[PASSWORD_FIELD]", "TABLE", "TEXT_BOX_NAME = [USER_NAME]")
PassW_TextBox = varX

End Sub

The password fills the Text Box. You can set a Field True/False for users confirm or ignore the password remeber next time it opens.

hope it hels

Best Regards

---
JoaoTL
NOSPAM_mail@jtl.co.pt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top