Rocky Smolin
rockysmolin at bchacc.com
Thu Apr 29 22:13:32 CDT 2010
Doug: I think that may be the answer. I was looking at the code and coming to the conclusion that I needed two db objects - one for the source and one for the target db, since one or both might have a password. Then have to figure out how to make two tdfs and get them to work together. Your way looks way simpler. Rocky -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Doug Steele Sent: Thursday, April 29, 2010 6:04 PM To: Access Developers discussion and problem solving Subject: Re: [AccessD] More Password Stuff FWIW, here is the heart of the code that I use - basically, it drops then recreates the tdf, rather than relinking it: DoCmd.RunSQL "Drop table [" & thistable & "]" Set tdf = CurrentDb.CreateTableDef(thistable) tdf.Connect = ";DATABASE=" & myr!dbPath & myr!DBName & ".mdb;pwd=" & "zzyzzz" tdf.SourceTableName = thistable CurrentDb.TableDefs.Append tdf Doug On Thu, Apr 29, 2010 at 4:00 PM, Rocky Smolin <rockysmolin at bchacc.com>wrote: > Dear List: > > I'm making some progress on this user's requirement to password > protect his back end. He says it's OK to hard code his password in > the front end (it's an mde). > > But I ran into a problem relinking the back end. I'm using Tribble's > relinker (with some minor mods) - and I need it because this app > supports multiple back ends - there's a database Open utility which > allows the user to open a copy of the back end or any other back end > cloned from the original delivered back end (no modifications to the tables, please). > > I get to this piece of code where the link is refreshed: > > For Each tdf In db.TableDefs > > Call frmProgressMeter.pmIncrement( _ > strIncrementMessage:="Checking table: " & tdf.Name) > > If Len(tdf.Connect) > 0 Then > > intI = intI + 1 > > If InStr(1, gstrRegisteredName, "ABC") <> 0 Then > tdf.Connect = ";DATABASE=" & varFileName & ";pwd='abcdefgh'" > Else > .Connect = ";DATABASE=" & varFileName End If > > > MsgBox tdf.Connect > ' The RefreshLink might fail if the new path > ' isn't OK. So trap errors inline. > On Error Resume Next > tdf.RefreshLink > > > If Err <> 0 And InStr(1, tdf.Name, "MWCI") = 0 Then > MsgBox strError, vbExclamation, "Table Link Failure - " & tdf.Name & > Err > Application.Quit > End If > > > End If > > > varFileName contains the patha and name of then back end. > > The app starts out linked to a back end that has no password. I use the > app's Open a Database Utility to point to the back end with the password > and > call Tribble's Relinker. > > If the registered user name contains ABC (true in this case) then I set the > Connect property of the Table Def (tdf) using the password. Otherwise, > not. > > When it comes down to tdf.RefreshLink, I get an 'Invalid Password' error. > > Does anyone know why this should happen? > > > > MTIA > > > > Rocky Smolin > > Beach Access Software > > 858-259-4334 > > www.e-z-mrp.com <http://www.e-z-mrp.com/> > > www.bchacc.com <http://www.bchacc.com/> > > > > > > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > > -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com