Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Nov 2001
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Relationship in remote db (Access 2000)

    I am very puzzled why one of my functions of creating relationships is working excellent, this is the function called LinkCallsCustomers
    and the other function built in exactly the same way, does not work this is the function LinkOrdersToOrderDetails.
    Is it possible that i have a mistake somewhere in my second function,and is there another way to try ?
    Below are my two functions


    Public Function LinkCallsCustomers()
    On Error Resume Next
    Dim wsp As DAO.Workspace
    Dim StrPassword As String
    StrPassword = "secret"
    Dim tdf As DAO.TableDef
    Dim fld As DAO.Field
    Set wsp = DAO.DBEngine.Workspaces(0)
    Dim dbs As DAO.Database
    Dim rel As DAO.Relation
    Dim tdf1 As DAO.TableDef
    Dim tdf2 As DAO.TableDef
    Set dbs = wsp.OpenDatabase("C:BEstoreBE.mdb", False, False,

    ";PWD=" & StrPassword)

    With dbs
    Set tdf1 = .TableDefs!customers
    Set tdf2 = .TableDefs!CallsCustomers
    Set rel = .CreateRelation("CustomerIDRelationship", tdf1.Name,

    tdf2.Name, dbRelationUpdateCascade)

    rel.Fields.Append rel.CreateField("CustomerID")
    rel.Fields!Customerid.ForeignName = "CustomerID"
    .Relations.Append rel
    .Close
    End With
    End Function
    ==============================
    Public Functions LinkOrdersToOrderDetails()
    ' links the tables orders and [order details]
    On Error Resume Next
    Dim wsp As DAO.Workspace
    Dim StrPassword As String
    StrPassword = "secret"
    Dim tdf As DAO.TableDef
    Dim fld As DAO.Field
    Set wsp = DAO.DBEngine.Workspaces(0)
    Dim dbs As DAO.Database
    Dim rel As DAO.Relation
    Dim tdf1 As DAO.TableDef
    Dim tdf2 As DAO.TableDef
    Set dbs = wsp.OpenDatabase("C:BEstoreBE.mdb", False, False,

    ";PWD=" & StrPassword)
    With dbs
    Set tdf1 = .TableDefs!orders
    Set tdf2 = .TableDefs![order details]
    Set rel = .CreateRelation("orderIDRelationship", tdf1.Name,

    tdf2.Name, dbRelationUpdateCascade)

    rel.Fields.Append rel.CreateField("orderID")
    rel.Fields!Customerid.ForeignName = "orderID"
    .Relations.Append rel
    .Close
    End With
    End Function

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Relationship in remote db (Access 2000)

    So what is the error you get, and on which line of the function does it occur?

  3. #3
    2 Star Lounger
    Join Date
    Nov 2001
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Relationship in remote db (Access 2000)

    Thank you for your reply.I do not get any error,but the tables orders and order details are not linked in one to many relationship when i check it..I am puzzled since with the other function it works and i can see the links created.But in this case no error occrus but nothing is created

    Best regards

  4. #4
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Relationship in remote db (Access 2000)

    You have:
    Public Functions LinkOrdersToOrderDetails()
    ' links the tables orders and [order details]
    On Error Resume Next
    Dim wsp As DAO.Workspace
    Dim StrPassword As String
    StrPassword = "secret"
    Dim tdf As DAO.TableDef
    Dim fld As DAO.Field
    Set wsp = DAO.DBEngine.Workspaces(0)
    Dim dbs As DAO.Database
    Dim rel As DAO.Relation
    Dim tdf1 As DAO.TableDef
    Dim tdf2 As DAO.TableDef
    Set dbs = wsp.OpenDatabase("C:BEstoreBE.mdb", False, False,

    ";PWD=" & StrPassword)
    With dbs
    Set tdf1 = .TableDefs!orders
    Set tdf2 = .TableDefs![order details]
    Set rel = .CreateRelation("orderIDRelationship", tdf1.Name,

    tdf2.Name, dbRelationUpdateCascade)

    rel.Fields.Append rel.CreateField("orderID")
    rel.Fields!Customerid.ForeignName = "orderID"
    .Relations.Append rel
    .Close
    End With
    End Function

    Is the bolded code correct?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •