473,326 Members | 2,111 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,326 software developers and data experts.

Relink just not right....can someone help me please

At first I thought I could just delete the tables and import the
tables. BUT my tables have relationships and I can not delete
a table with relations. So that only deleted the non relational tables
and imported them.
Now I am trying to relink the exported tables.
this is the code I am using
Public Function ReLink() As Boolean
On Error Resume Next
Dim astrTableNames(1000) As String
Dim iintTableNames As Integer
Dim intI As Integer, strTableName As String, strServer As String
Dim rst0 As Recordset
Dim dbs As Database
Set rst0 = CurrentDb.OpenRecordset("tlkpSysInfo")
strServer = Nz(rst0!extLocation)
rst0.Close
Set dbs = DBEngine.Workspaces(0).OpenDatabase(strServer, ,
dbReadOnly)
dbs.TableDefs.Refresh
For intI = 0 To dbs.TableDefs.Count - 1
strTableName = dbs.TableDefs(intI).Name
If Left$(strTableName, 3) = "tbl" Then
iintTableNames = iintTableNames + 1
astrTableNames(iintTableNames) = strTableName
End If
Next intI
Set dbs = Nothing
For intI = 1 To iintTableNames
Call TableDelete(astrTableNames(intI))
Next intI
CurrentDb.TableDefs.Refresh
For intI = 1 To iintTableNames
Call TableLink(strServer, astrTableNames(intI),
astrTableNames(intI))
Next intI
On Error GoTo 0
ReLink = True
End Function
================
Public Function TableLink(strLocation As String, strOldName As String,
strNewName As String) As Boolean
On Error Resume Next
DoCmd.TransferDatabase acLink, "Microsoft Access", strLocation,
acTable, strOldName, strNewName
If Err Then
TableLink = False
Else
TableLink = True
End If
On Error GoTo 0
End Function
===================
Public Function TableDelete(strTableName As String) As Integer
On Error Resume Next
DoCmd.DeleteObject A_TABLE, strTableName
MsgBox "deleting " & strTableName
If Err Then
TableDelete = False
Else
TableDelete = True
End If
On Error GoTo 0
End Function
I thought this would work but at best it will do
is for any existing table

tbltest
tblwork
tbldata

tbltest
tbltest1
tblwork
tblwork1
tbldata
tbldata1

the same as when I tried to delete and import.

can someone tell me how to delete or relink these tables with
relationships without getting incrememtal files?

thank you for any and all help
jerry


Nov 12 '05 #1
1 1748
sparks <sp****@here.com> wrote in message news:<t7********************************@4ax.com>. ..
At first I thought I could just delete the tables and import the
tables. BUT my tables have relationships and I can not delete
a table with relations. So that only deleted the non relational tables
and imported them.
Now I am trying to relink the exported tables.
this is the code I am using
Public Function ReLink() As Boolean
On Error Resume Next
Dim astrTableNames(1000) As String
Dim iintTableNames As Integer
Dim intI As Integer, strTableName As String, strServer As String
Dim rst0 As Recordset
Dim dbs As Database
Set rst0 = CurrentDb.OpenRecordset("tlkpSysInfo")
strServer = Nz(rst0!extLocation)
rst0.Close
Set dbs = DBEngine.Workspaces(0).OpenDatabase(strServer, ,
dbReadOnly)
dbs.TableDefs.Refresh
For intI = 0 To dbs.TableDefs.Count - 1
strTableName = dbs.TableDefs(intI).Name
If Left$(strTableName, 3) = "tbl" Then
iintTableNames = iintTableNames + 1
astrTableNames(iintTableNames) = strTableName
End If
Next intI
Set dbs = Nothing
For intI = 1 To iintTableNames
Call TableDelete(astrTableNames(intI))
Next intI
CurrentDb.TableDefs.Refresh
For intI = 1 To iintTableNames
Call TableLink(strServer, astrTableNames(intI),
astrTableNames(intI))
Next intI
On Error GoTo 0
ReLink = True
End Function
================
Public Function TableLink(strLocation As String, strOldName As String,
strNewName As String) As Boolean
On Error Resume Next
DoCmd.TransferDatabase acLink, "Microsoft Access", strLocation,
acTable, strOldName, strNewName
If Err Then
TableLink = False
Else
TableLink = True
End If
On Error GoTo 0
End Function
===================
Public Function TableDelete(strTableName As String) As Integer
On Error Resume Next
DoCmd.DeleteObject A_TABLE, strTableName
MsgBox "deleting " & strTableName
If Err Then
TableDelete = False
Else
TableDelete = True
End If
On Error GoTo 0
End Function
I thought this would work but at best it will do
is for any existing table

tbltest
tblwork
tbldata

tbltest
tbltest1
tblwork
tblwork1
tbldata
tbldata1

the same as when I tried to delete and import.

can someone tell me how to delete or relink these tables with
relationships without getting incrememtal files?

thank you for any and all help
jerry


That's a lot of code, and I haven't reviewed it all in any detail, but
at first glance, it *might* be the way you're deleting the existing
linked tables. When you delete a table, the TableDefs collection is
re-indexed, so when you delete TableDefs(0), the table that used to be
TableDefs(1) becomes TableDefs(0). If you then delete TableDefs(1),
you're deleting the table that used to be TableDefs(2) - the former
TableDefs(1), now TableDefs(0), never gets deleted.

One way around this is to loop backwards ...

For tdf = db.TableDefs.Count - 1 to 0 Step - 1

--
Brendan Reynolds
Nov 12 '05 #2

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

Similar topics

3
by: Random Person | last post by:
Does anyone know how to use VBA to relink tables between two MS Access databases? We have two databases, one with VBA code and the other with data tables. The tables are referenced by linked...
3
by: Jim | last post by:
I have a database with a front and back end setup as follows: Front: \\nt\database\NewDB\Stats.mdb = forms, reports, queries Back: "\\nt\database\NewDB\StatsData.mdb" = tables When the...
11
by: DraguVaso | last post by:
Hi, I want to make a small application in VB.NET that relinks all the query's and tables in an Access database that are linked via ODBC to an SQL Server. It must be able to relink all the tables...
0
by: DraguVaso | last post by:
Hi, I need to relink a whole bunch of Access-Linked-Tables and Pass-Through-Query's to another ODBC with VB.NET I foudn alreaddy how to relink the Tables, and I thought the query's woudl be...
12
by: lesperancer | last post by:
I've got two MDBs, that due to size, security, etc, need to be kept separate quotation configurator (there will be more of these in the future) so within quotation.mdb, I linked all the...
2
by: Dan M | last post by:
I just learned that the version of OpenSSL I'm running (on a RedHat EL) server has some vulnerabilities that I'd like to close. I'm running PHP 5.1.4. My question is this: I've got PHP 5.1.4, and...
2
by: cranfan | last post by:
I'm using a relink method.It works fine but i have a question about making it work fast. If .Tables(tdfRelink.name).Type = "LINK" Then in this line i put a breakpoint and look for the table...
1
by: Coni | last post by:
Hello, I am following steps to implement security on access 2003 through distribution: I have split the database and I am trying to distribute it: I have copied the back end file and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.