473,427 Members | 1,741 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,427 software developers and data experts.

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

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!


Dec 10 '05 #1
5 1683
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.

--
Terry Kreft

"Jozef" <me@you.com> wrote in message
news:c9qmf.142332$y_1.124960@edtnps89...
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!


Dec 10 '05 #2
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?
"Terry Kreft" <te*********@mps.co.uk> wrote in message
news:-Z********************@karoo.co.uk...
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.

--
Terry Kreft

"Jozef" <me@you.com> wrote in message
news:c9qmf.142332$y_1.124960@edtnps89...
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!



Dec 10 '05 #3
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.

On Sat, 10 Dec 2005 01:26:32 GMT, "Jozef" <me@you.com> wrote:
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!



Dec 10 '05 #4
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


--
Terry Kreft

"Jozef" <me@you.com> wrote in message news:uiJmf.145841$S4.61975@edtnps84...
<SNIP>
refreshing the attachments by doing Currentdb.TableDefs.Refresh, but still <SNIP> (other than the indirect source table modifications). Does that make
sense?
"Terry Kreft" <te*********@mps.co.uk> wrote in message
news:-Z********************@karoo.co.uk...
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.

--
Terry Kreft

"Jozef" <me@you.com> wrote in message
news:c9qmf.142332$y_1.124960@edtnps89...
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!




Dec 12 '05 #5
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!

"Terry Kreft" <te*********@mps.co.uk> wrote in message
news:pO********************@karoo.co.uk...
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


--
Terry Kreft

"Jozef" <me@you.com> wrote in message
news:uiJmf.145841$S4.61975@edtnps84...
<SNIP>
refreshing the attachments by doing Currentdb.TableDefs.Refresh, but
still

<SNIP>
(other than the indirect source table modifications). Does that make
sense?
"Terry Kreft" <te*********@mps.co.uk> wrote in message
news:-Z********************@karoo.co.uk...
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.

--
Terry Kreft

"Jozef" <me@you.com> wrote in message
news:c9qmf.142332$y_1.124960@edtnps89...
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!





Dec 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ishwor | last post by:
hi check your seperator variable in the os module. :) for example >>> import os >>> os.sep '\\' Now what you do is :- >> os.listdir("D:" + os.sep + "any_other_folder_name" + os.sep); :)
0
by: JL | last post by:
Hi there I have a database with entries like the following: Id, Name, Goals_season, Goals_total ---------------------------------------- 5, John, 5, 23 6, Mike, 2, 14 7, Joe, 10, 34 Every...
1
by: TJRobertsJob | last post by:
Was wondering if someone could help. Over the last month I've been developing a small database application, using Access 2000, for use in a friends shop. Everything was going well until about a...
1
by: PeteCresswell | last post by:
I'm working on a new report in an MS Access DB. The first anomaly was a message "This action will reset the current code in break mode." when the report was run. Seems TB something about my...
4
by: MLH | last post by:
The following function declaration confuses me... Public Function IsEMailAddress(ByVal sEmail As String, Optional ByRef sReason As String) As Boolean I tried pasting it and its code into an...
2
by: THY | last post by:
Hi, I am having some problem, I declare few variable in a public module and use them in the web application. But after that I found that the variable declared in public variable =...
5
by: Alex Maghen | last post by:
Hi. Is there a way to make a call in ASP.NET that will effectively do exactly the same thing is when you "touch"/change the web.config file? In other words, I want to be able to programmatically...
53
by: Sanders Kaufman | last post by:
I'm having a BLAST writing this app as OOP as PHP allows. It's one thing to discuss the dance, but it's a thing of beauty to see the performance. I'm noticing that the constructor is a "reset"...
10
by: Lorenzo Di Gregorio | last post by:
Hello, I've been using Python for some DES simulations because we don't need full C speed and it's so much faster for writing models. During coding I find it handy to assign a variable *unless...
12
Frinavale
by: Frinavale | last post by:
I think I'm trying to do something impossible. I have a <div> element with a overflow style set to "scroll". In other words my <div> element allows the user to scroll the content within it. ...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.