Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Posts
    254
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Create lookup field in remote table (Access 2000)

    I have a function that creates fields in the table Customers.It works.
    However,this time i have to create a lookup field, looking up for thef field Type in the

    table Types.I do not see how to create this property in my function.
    Can somebody help me with the function below?

    Public Function CreateFieldsInCustomers()
    On Error GoTo ErrProc

    Dim StrPassword As String
    StrPassword = "secret"
    Dim wsp As DAO.Workspace
    Dim dbs As DAO.Database
    Dim tdf As DAO.TableDef
    Dim fld As DAO.Field
    Set wsp = DAO.DBEngine.Workspaces(0)
    Set dbs = wsp.OpenDatabase("C:BEstoreBE.mdb", False, False, ";PWD=" &

    StrPassword)

    Set tdf = dbs.TableDefs("Customers")


    ' create the field TypeID

    Set fld = tdf.CreateField("TypeID", dbSingle)
    tdf.Fields.Append fld

    tdf.Fields.Refresh
    dbs.Close
    Set fld = Nothing
    Set tdf = Nothing
    Set dbs = Nothing
    Set wsp = Nothing
    Exit Function
    ErrProc:
    If Err = 3191 Then
    Resume Next
    Else
    MsgBox Err.Description ' or something else you want
    End If
    End Function

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Create lookup field in remote table (Access 2000)

    There is no such think as a Lookup property for fields in a table. The database engine does the lookup bit based on the relationships that are established between tables. That can be manipulated in code, but you are potentially playing with fire if you are trying to maintain referential integrity in your database.
    Wendell

Posting Permissions

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