Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / December 2005

Tip: Looking for answers? Try searching our database.

Attachments lost/reset once public db variable is set to ""

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jozef - 10 Dec 2005 01:26 GMT
Hello,

I have an Access XP database that has attachments to a BE database that has
a password.  The attachments work fine, until I run some code that modifies
a BE table (adding a field).  I do this by running code similar the
following;

Public varDb as DAO.database
sub ConnectBEDatabase(strLocation as string)
   Set varDb = OpenDatabase(strLocation, False, False, ";pwd=" &
GetPassword())
end sub

sub DisconnectBEDatabase()
   set varDB=nothing
end sub

function GetPassword()
   getpassword="MyPassword"
end function

public Sub UpdateBE()
   ConnectBEDatabase("C:\MyDatabase.mdb")
-----code to add a field to a table-----

-----end code to add a field-----
DisconnectBEDatabase
end sub

The problem is, once I run the disconnect, my table attachments all of a
sudden say "Not a valid password" or something of the like.  I'm not
modifying the connectd strings or anything, just modifying the back end
tabledef.

Any ideas?

Thanks!
Terry Kreft - 10 Dec 2005 12:12 GMT
Firstly if your posting a problem where a particular error message is given
it's best to take the time to quote the full error rather than quoting
something you vaguely remember.

Are you refreshing the links to the BE tables that you are modifying? If you
don't do this you will get errors if the BE tables are changed.

Signature

Terry Kreft

> Hello,
>
[quoted text clipped - 33 lines]
>
> Thanks!
Jozef - 10 Dec 2005 23:13 GMT
Pardon me, the EXACT  error is "Not a valid password" rather than something
like "Not a valid password".  Hope that clarifies things.  I've tried
refreshing the attachments by doing Currentdb.TableDefs.Refresh, but still
get the same exact error message.  Before the disconnect the attachments are
fine, and I don't get the message until the disconnect occurs.  I could see
a possibility of this happening if I was manipulating the attachments with
the varDb variable, but theres no code that even touches the attachment
(other than the indirect source table modifications).  Does that make sense?

> Firstly if your posting a problem where a particular error message is
> given it's best to take the time to quote the full error rather than
[quoted text clipped - 40 lines]
>>
>> Thanks!
Terry Kreft - 12 Dec 2005 10:19 GMT
Yes, it makes sense now, you nearly got the right method, what you need to
do is use the RefreshLink method of the tabledef object.

So if the table you've modified is called tblMyTable (this is it's name in
the local database, i.e. the linked table not the source table in the BE
db), you would do something like

Currentdb.Tabledefs("tblMyTable ").Refreshlink

If you wanted to do all the linked tables you can do something like:-

Dim loDB as DAO.Database
Dim loTab as as DAO.Tabledef

set loDb = CurrentDB

For Each lotab in loDB.Tabledefs
   with loTab
       if Len(.Connect)>0 then
           .Refreshlink
       end if
   End with
next

Signature

Terry Kreft

<SNIP>
> refreshing the attachments by doing Currentdb.TableDefs.Refresh, but still
<SNIP>
> (other than the indirect source table modifications).  Does that make
> sense?
[quoted text clipped - 43 lines]
>>>
>>> Thanks!
Jozef - 12 Dec 2005 15:14 GMT
Thanks Terry,

I did add that and also created a separate workspace for the db, and it
seems to work fine now.

Thanks for your help!

> Yes, it makes sense now, you nearly got the right method, what you need to
> do is use the RefreshLink method of the tabledef object.
[quoted text clipped - 71 lines]
>>>>
>>>> Thanks!
Steve Jorgensen - 10 Dec 2005 23:27 GMT
I don't know if this relates, but when you obtain a DAO Database reference via
OpenDatabase, you should also call .Close on it before you let it go out of
scope.

>Hello,
>
[quoted text clipped - 33 lines]
>
>Thanks!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.