473,795 Members | 2,498 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 ConnectBEDataba se(strLocation as string)
Set varDb = OpenDatabase(st rLocation, False, False, ";pwd=" &
GetPassword())
end sub

sub DisconnectBEDat abase()
set varDB=nothing
end sub

function GetPassword()
getpassword="My Password"
end function

public Sub UpdateBE()
ConnectBEDataba se("C:\MyDataba se.mdb")
-----code to add a field to a table-----

-----end code to add a field-----
DisconnectBEDat abase
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 1702
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.1423 32$y_1.124960@e dtnps89...
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 ConnectBEDataba se(strLocation as string)
Set varDb = OpenDatabase(st rLocation, False, False, ";pwd=" &
GetPassword())
end sub

sub DisconnectBEDat abase()
set varDB=nothing
end sub

function GetPassword()
getpassword="My Password"
end function

public Sub UpdateBE()
ConnectBEDataba se("C:\MyDataba se.mdb")
-----code to add a field to a table-----

-----end code to add a field-----
DisconnectBEDat abase
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.Table Defs.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*********@mp s.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.1423 32$y_1.124960@e dtnps89...
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 ConnectBEDataba se(strLocation as string)
Set varDb = OpenDatabase(st rLocation, False, False, ";pwd=" &
GetPassword())
end sub

sub DisconnectBEDat abase()
set varDB=nothing
end sub

function GetPassword()
getpassword="My Password"
end function

public Sub UpdateBE()
ConnectBEDataba se("C:\MyDataba se.mdb")
-----code to add a field to a table-----

-----end code to add a field-----
DisconnectBEDat abase
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 ConnectBEDataba se(strLocation as string)
Set varDb = OpenDatabase(st rLocation, False, False, ";pwd=" &
GetPassword( ))
end sub

sub DisconnectBEDat abase()
set varDB=nothing
end sub

function GetPassword()
getpassword="My Password"
end function

public Sub UpdateBE()
ConnectBEDataba se("C:\MyDataba se.mdb")
-----code to add a field to a table-----

-----end code to add a field-----
DisconnectBEDa tabase
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.Table defs("tblMyTabl e ").Refreshl ink

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.1458 41$S4.61975@edt nps84...
<SNIP>
refreshing the attachments by doing Currentdb.Table Defs.Refresh, but still <SNIP> (other than the indirect source table modifications). Does that make
sense?
"Terry Kreft" <te*********@mp s.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.1423 32$y_1.124960@e dtnps89...
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 ConnectBEDataba se(strLocation as string)
Set varDb = OpenDatabase(st rLocation, False, False, ";pwd=" &
GetPassword())
end sub

sub DisconnectBEDat abase()
set varDB=nothing
end sub

function GetPassword()
getpassword="My Password"
end function

public Sub UpdateBE()
ConnectBEDataba se("C:\MyDataba se.mdb")
-----code to add a field to a table-----

-----end code to add a field-----
DisconnectBEDat abase
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*********@mp s.co.uk> wrote in message
news:pO******** ************@ka roo.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.Table defs("tblMyTabl e ").Refreshl ink

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.1458 41$S4.61975@edt nps84...
<SNIP>
refreshing the attachments by doing Currentdb.Table Defs.Refresh, but
still

<SNIP>
(other than the indirect source table modifications). Does that make
sense?
"Terry Kreft" <te*********@mp s.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.1423 32$y_1.124960@e dtnps89...
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 ConnectBEDataba se(strLocation as string)
Set varDb = OpenDatabase(st rLocation, False, False, ";pwd=" &
GetPassword())
end sub

sub DisconnectBEDat abase()
set varDB=nothing
end sub

function GetPassword()
getpassword="My Password"
end function

public Sub UpdateBE()
ConnectBEDataba se("C:\MyDataba se.mdb")
-----code to add a field to a table-----

-----end code to add a field-----
DisconnectBEDat abase
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
465
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
1295
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 season we have to reset the "Goals_season" column to the default value
1
6695
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 week ago when I started getting the following error when I would click any buttons on my main form that ran either VB code or an Access Macro: "Error accessing file. Network connection may have been lost.". I know for sure it's not a network...
1
2685
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 Detail1_Print(): if I answer "No" to the dialog the report just runs. If I answer "Yes", it pops a new dialog seemingly at every line. Code is below. The real zinger, however, started on Friday. When I run the report in question somehow MS...
4
2674
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 Access 2.0 module. I was unsuccessful. I had to remove the following... "Public" "Optional ByRef" "As Boolean"
2
1729
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 = application("variable"), and it will be shared by all user ... but I am not very sure about it, anyone know it ? Thanks, Tee
5
2165
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 cause the same kind of general resetting that happens when you touch the web.config file. Alex
53
3028
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" switch - just like the one on the front of my computer. Calling it seems to just dump all of the old values, free up all of the old resources, and return the object to a pristine state. However, I'm a *little* concerned about just using the...
10
1511
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 it has been already assigned*: I've found that this is often referred to as "once" assigment. The best I could come up with in Python is:
12
7889
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. There are a number of elements within this <div> that cause the <div> to participate in an Ajax call to the server. In order to maintain the scroll position of the <div> during the Ajax request I store the scroll value in a hidden field so that when...
0
10436
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10000
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9040
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5436
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3722
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.