472,353 Members | 1,419 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 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 1668
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...
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:...
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...
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...
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) ...
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...
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...
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...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
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....
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...

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.