472,373 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Linking and disconnecting from backend databases

cmd
I use a utility database and the following code to link from an
original backend to a temporary backend, in order to replace the
original with a newer version:

Dim dbs As Database
Dim tdf As TableDef
Dim Tdfs As TableDefs
Dim Pathname As String
Set dbs = CurrentDb
Set Tdfs = dbs.TableDefs

'LINKING TO THE ORIGINAL BACKEND
Pathname = "C:\Access97\fpsdata.mdb"
For Each tdf In Tdfs
On Error Resume Next
If tdf.SourceTableName <> "" Then
tdf.Connect = ";DATABASE=" & Pathname
tdf.RefreshLink 'Refresh the link
End If
Next 'Goto next table

'LINKING TO A TEMPORARY BACKEND:

Pathname = "C:\Transfer\fpsdata.mdb"
For Each tdf In Tdfs
On Error Resume Next
If tdf.SourceTableName <> "" Then
tdf.Connect = ";DATABASE=" & Pathname
tdf.RefreshLink 'Refresh the link
End If
Next 'Goto next table

'ATTEMPTING TO REPLACE THE FIRST BACKEND WITH ANOTHER VERSION:

Filecopy "C:\NewVersion\fpsdata.mdb, "C:\Access97\fpsdata.mdb"

-- THE FILECOPY ACTION FAILS TO REPLACE C:\Access97\fpsdata.mdb. THE
PROBLEM IS THAT THE UTILITY DATABASE I'M IN EVIDENTLY DOES NOT FULLY
RELEASE OR CLOSE C:\ACCESS97\FPSDATA.MDB, EVEN AFTER LINKING TO THE
SECOND DATABASE.

DO I NEED TO SET 'dbs' AND 'Tdfs' TO NOTHING SOMEWHERE ALONG THE WAY
--AND THEN RE-SET THEM PRIOR TO DOING ANOTHER TABLE-LINK?

THANK YOU.
MARK.

Nov 13 '05 #1
2 3251

<cm*@mountain.net> schreef in bericht news:11*********************@o13g2000cwo.googlegro ups.com...
I use a utility database and the following code to link from an
original backend to a temporary backend, in order to replace the
original with a newer version:

<snip code >

Hi Mark,
IMO it's a bit unusual to replace the backend. Mostly we replace the Frontend don't we ??
If you replace the backend, well why would you do so ? You will lose all new data ??
Is this some kind of restore procedure ??

==>> IMO there is NO need to link to another db to replace the file.
To replace the backend this is what I think you need:
You need to make sure there is no 'active' connection; no open recordsets,
And also: No open form with bound controls !

I just tested:
I Opened one of the Access 97 applications I have: (fe-be).
My main menu opens (unbound)
From this menu I click on a button with code like:

Private Sub Button_Click()
FileCopy "C:\ArraCom\Klavier\kla_be.bak", "C:\ArraCom\Klavier\kla_be.mdb"
End Sub

This works and replaces the backend.
If I also have opened one of the bound forms then: No go (error: access refused)
If I close the bound form again: Code works OK

--
Hope this helps
Arno R
Nov 13 '05 #2
cmd
Thanks Arno,
This involves updating a user's home computer with data from the
office. The "parent" records for the backend database are based on
client-id numbers (autonumber), with a lot of different types of
"child" records associated with each client-id number. The user does
not add "parent" records, but does create and edit "child" records on
their home computer.

The task is to allow the user to retain their edited/created "child"
records on their home computer, while updating their backend in order
to receive any new "parent" records added at the main office.

Therefore, I was using the utility database to first link to the user's
backend database to retrieve any edited/created "child" records of
theirs. After replacing their backend database with the newer office
copy, the retrieved "child" records are appended, based on matching
client-id numbers. (Actually, any MATCHING "child" records are adjusted
for edits; then any unmatching "child" records are appended).

I've re-thought the approach, however; now I simply open the utility
database and before refreshing any links, use FileCopy to create a
Temp.mdb of their existing backend database. Then I can simply replace
their database with the office version, refresh links to the Temp.mdb
and retrieve (and later append) the user's "child" records from that
database. This avoids refreshing links to the "real" backend databases,
which interferes with the copy process.

Nov 13 '05 #3

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

Similar topics

10
by: Squirrel | last post by:
I posted a question a couple of days ago about running different versions of Access for the frontend versus the backend databases. Got some good advice but now I've received this information: ...
0
by: gasturbtec | last post by:
please help im new at access programming and i just got this project dropped in my lap because the old programmer quit. i've been doing ok so far but now i need to add code to an existing database...
2
by: jayjay | last post by:
In the database I have, its split into front end screens and reports and backend tables for data. Of course, this means the linked tables are linked using the linked table wizard to the network...
16
by: John | last post by:
Hi All, I have two backend databases that area link to a frontend database where information is entered, retrieved and deleted. The information accessed from the frontend database is coming from...
3
by: Mark | last post by:
Hi All, Firstly, I am aware from reading previous posts that if someone is determined enough, they will crack an Access Application. However, this problem seems basic but I can't find a...
1
by: Daveyk0 | last post by:
Hello there, I have a front end database that I have recently made very many changes to to allow off-line use. I keep copies of the databases on my hard drive and link to them rather than the...
10
by: Jennifer Carr | last post by:
I have an Access 2003 application that is split into two .mdb files for the interfaces and data. This app is distributed on a CD to be used on computers that have no internet access. When someone...
2
by: watto | last post by:
I have a large database application with user data in a backend and forms, code etc in a frontend. It includes a facility for migrating data from an earlier backend to the current backend by...
7
by: Salad | last post by:
I am converting an application from A97 to A2003. I have 2 tables created by another application as a Foxpro.dbf. The table has no index. The connect string in A97 is FoxPro...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

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.