Open the recordset, designating that the source is a SQL statement based on more than one table : Table Join « Access « VBA / Excel / Access / Word






Open the recordset, designating that the source is a SQL statement based on more than one table

 
Sub InconsistentUpdates()
    Dim rst As ADODB.Recordset
    Set rst = New ADODB.Recordset

    rst.ActiveConnection = CurrentProject.Connection
    rst.CursorType = adOpenStatic
    rst.LockType = adLockOptimistic

    rst.Properties("Jet OLEDB:Inconsistent") = True
    rst.Open Source:="Select * from Employees " & _
        "INNER JOIN Projects " & _
        "ON Employees.ClientID = Projects.ClientID", _
        Options:=adCmdText

    'Modify the contents of the foreign key field
    rst("Projects.ClientID") = 1
    rst.Update
    Debug.Print rst("Projects.ClientID")

    rst.Close
    Set rst = Nothing

End Sub

 








Related examples in the same category

1.Establishing Relationships Using Code