"Geir Baardsen" <ge***********@hotmail.com> skrev i melding
news:35**************************@posting.google.c om...
Hi!
I wonder if anybody can help with the following:
I need to password-protect tables in MyBackEnd.DB, which is placed in
the same folder as the MyFrontEnd.DB
Now I've tried the KB_209953 article in the microsoft knowledge-base,
and I also looked
up the module example in the developer 2000 edition.
They both produces the error: "Invalid password".
I've checked that Capslock is not on, I've checked the path to the
MyBackEnd.DB,
and I've checked....
So, anybody that really got a working thing on:
1. Check the link to the MyBackEnd.DB
(in the OnOpen-event of 'frmMain' of MyFrontEnd.DB)
and maybe refresh the link (without user interaction)?
2. Open the password-protected MyBackEnd.DB
(in the OnOpent-event of frmMain of MyFrontEnd.DB) ?
Me.Name
Can this code give you some idea?
Private Function RefreshLinks(strFileName As String) As Boolean
' Refresh links to the supplied database. Return True if successful.
Dim dbsOrders As DAO.Database
Dim tdf As DAO.TableDef
Dim intCount As Integer
Dim strPassword As String
strPassword = "12345678901234567890"
On Error GoTo Errorhandler
' Loop through all tables in the database.
Set dbsOrders = CurrentDb
For intCount = 0 To dbsOrders.TableDefs.Count - 1
Set tdf = dbsOrders.TableDefs(intCount)
' If the table has a connect string, it's a linked table.
If Len(tdf.Connect) > 0 Then
tdf.Connect = ";DATABASE=" & strFileName & ";PWD=" & strPassword
Err.Number = 0
On Error Resume Next
tdf.RefreshLink ' Relink the table.
If Err.Number <> 0 Then
RefreshLinks = False
Exit Function
End If
End If
Next intCount
RefreshLinks = True ' Relinking complete.
Exit Function
Errorhandler:
MsgBox "Error#: " & Err.Number & vbCrLf & Err.Description
RefreshLinks = False
End Function
--
____________________________
Sigurd Bruteig
www.made4u.no