Re: TSI Un-replicator not working ?

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hi Graham,

I have a problem with your util. It doesn't copy the relationships.
Everything else (AFAIK) works great. But I get error "3284: Index
already exists" when I get to

dbC.Relations.Append relC

I tried another piece of code, that copy relationships (I think I got
ot from MS KB) and that gives the same error, when trying to add the
relationship. I also tried the code in a clean new DB, created 2 tables
(same names as my replicated db-tables) and ran the code. And it worked
fine. It copied the relationship.

Here is the code btw, its basically the same just a bit more
self-contained:
Function ImportRelations(DbName As String) As Integer
'------------------------------------------------------------------
' PURPOSE: Imports relationships where table names and field names
' match.
' ACCEPTS: The name of the external database as a string.
' RETURNS: The number of relationships imported as an integer.
'------------------------------------------------------------------

Dim ThisDb As DAO.Database, ThatDB As DAO.Database
Dim ThisRel As DAO.Relation, ThatRel As DAO.Relation
Dim ThisField As DAO.Field, ThatField As DAO.Field
Dim Cr As String, i As Integer, cnt As Integer, RCount As Integer
Dim j As Integer
Dim ErrBadField As Integer

Cr$ = Chr$(13)
RCount = 0

Set ThisDb = CurrentDb()
Set ThatDB = DBEngine.Workspaces(0).OpenDatabase(DbName$)

' Loop through all existing relationships in the external database.
For i = 0 To ThatDB.Relations.Count - 1
Set ThatRel = ThatDB.Relations(i)

' Create 'ThisRel' using values from 'ThatRel'.
Set ThisRel = ThisDb.CreateRelation(ThatRel.Name, _
ThatRel.table, ThatRel.foreigntable, ThatRel.Attributes)

' Set bad field flag to false.
ErrBadField = False

' Loop through all fields in that relation.
For j = 0 To ThatRel.Fields.Count - 1
Set ThatField = ThatRel.Fields(j)

' Create 'ThisField' using values from 'ThatField'.
Set ThisField = ThisRel.CreateField(ThatField.Name)
ThisField.foreignname = ThatField.foreignname

' Check for bad fields.
On Error Resume Next
ThisRel.Fields.Append ThisField
If Err <> False Then ErrBadField = True
On Error GoTo 0
Next j

' If any field of this relationship caused an error,
' do not add this relationship.
If ErrBadField = True Then
' Something went wrong with the fields.
' Do not do anything.
Else
' Try to append the relation.
On Error Resume Next
ThisDb.Relations.Append ThisRel
If Err <> False Then
' Something went wrong with the relationship.
' Skip it.
Else
' Keep count of successful imports.
RCount = RCount + 1
End If
On Error GoTo 0
End If
Next i

' Close databases.
ThisDb.Close
ThatDB.Close

' Return number of successful imports.
ImportRelations = RCount

End Function

.



Relevant Pages

  • Re: Shared functions vs Non-Shared Functions
    ... > dim context as HttpContext = HttpContext.Current ... Imports Microsoft.VisualBasic ... Public Shared sub sendEmail ... >> dim webMasterEmail As String ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Importing text, etc. on remote .mdb file
    ... You can then use VBA string functions to get from there to the ... Is there an easy way to schedule the imports of the text files so I ... 'Modify strSQL and filenames as required ... Dim oJet 'DAO.DBEngine ...
    (microsoft.public.access.externaldata)
  • RE: Logon Error
    ... > Imports CrystalDecisions.CrystalReports ... > function is emailPDFwhich calls ChangeLogOnInfo EmailPDF returns a Report ... > Dim szErrorMailSecondary As String 'This is where all the mail messages ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: .net remoting vs SQL Server
    ... The connection to the database will only exist as long as the method runs. ... Imports System.Runtime.Remoting ... Public Function ConnectionString() As String ... Dim oCmd As SqlCommand = New SqlCommand ...
    (microsoft.public.dotnet.framework.remoting)
  • IIS Create Site in asp.net
    ... Imports System.Collections ... Dim oConn As New ConnectionOptions ... PathOfRootVirtualDir As String, ByVal ServerBindings() As ... ManagementBaseObject, ByVal ServerComment As String) As String ...
    (microsoft.public.win32.programmer.wmi)