The code below attempts to create a record in the tables listed and populating the PAR field (Primary Key) in each when a new project is added. The code adds rows to the tables but, the number of records does not increase.
Each of the tables a record is added to is linked to a backend access database.
Must I open the backend database and tables to perform these record additions or is there a way to accomplish this in the front end linked tables?
I have tried leaving options blank and as seen below.
Again rows are added to the tables but the number of records does not increase.
Any help you can provide is appreciated.
[code=vb]Sub TBLApprovalAddR ecord(Parqry)
Dim dbs As Database: Dim rst As Recordset: Set dbs = CurrentDb
Set rst = dbs.OpenRecords et("Originator" )
rst.MoveLast
Parqry = rst("PAR").Valu e
rst.Close: Set rst = Nothing
Set rst = dbs.OpenRecords et("Approvals" , dbOpenDynaset)
If rst.EOF And rst.BOF Then
With rst
.AddNew: .Fields!PAR = Parqry: .Update
End With
Else
With rst
.MoveLast
.AddNew
.Fields!PAR = Parqry
.Update
End With
End If
rst.Close: Set rst = Nothing
Set rst = dbs.OpenRecords et("PARTeam", dbOpenDynaset)
If rst.EOF And rst.BOF Then
With rst
.AddNew
.Fields!PAR = Parqry
.Update
End With
Else
With rst
.MoveLast: .AddNew: .Fields!PAR = Parqry: .Update
End With
End If
rst.Close: Set rst = Nothing
Set rst = dbs.OpenRecords et("TimeLine", dbOpenDynaset)
If rst.EOF And rst.BOF Then
With rst
.AddNew: .Fields!PAR = Parqry: .Update
End With
Else
With rst
.MoveLast: .AddNew: .Fields!PAR = Parqry: .Update
End With
End If
Set rst = dbs.OpenRecords et("CRAP", dbOpenDynaset)
If rst.EOF And rst.BOF Then
With rst
.AddNew
.Fields!PAR = Parqry
.Update
End With
Else
With rst
.MoveLast: .AddNew: .Fields!PAR = Parqry: .Update
End With
End If
rst.Close: Set dbs = Nothing
End Sub[/code]
Each of the tables a record is added to is linked to a backend access database.
Must I open the backend database and tables to perform these record additions or is there a way to accomplish this in the front end linked tables?
I have tried leaving options blank and as seen below.
Again rows are added to the tables but the number of records does not increase.
Any help you can provide is appreciated.
[code=vb]Sub TBLApprovalAddR ecord(Parqry)
Dim dbs As Database: Dim rst As Recordset: Set dbs = CurrentDb
Set rst = dbs.OpenRecords et("Originator" )
rst.MoveLast
Parqry = rst("PAR").Valu e
rst.Close: Set rst = Nothing
Set rst = dbs.OpenRecords et("Approvals" , dbOpenDynaset)
If rst.EOF And rst.BOF Then
With rst
.AddNew: .Fields!PAR = Parqry: .Update
End With
Else
With rst
.MoveLast
.AddNew
.Fields!PAR = Parqry
.Update
End With
End If
rst.Close: Set rst = Nothing
Set rst = dbs.OpenRecords et("PARTeam", dbOpenDynaset)
If rst.EOF And rst.BOF Then
With rst
.AddNew
.Fields!PAR = Parqry
.Update
End With
Else
With rst
.MoveLast: .AddNew: .Fields!PAR = Parqry: .Update
End With
End If
rst.Close: Set rst = Nothing
Set rst = dbs.OpenRecords et("TimeLine", dbOpenDynaset)
If rst.EOF And rst.BOF Then
With rst
.AddNew: .Fields!PAR = Parqry: .Update
End With
Else
With rst
.MoveLast: .AddNew: .Fields!PAR = Parqry: .Update
End With
End If
Set rst = dbs.OpenRecords et("CRAP", dbOpenDynaset)
If rst.EOF And rst.BOF Then
With rst
.AddNew
.Fields!PAR = Parqry
.Update
End With
Else
With rst
.MoveLast: .AddNew: .Fields!PAR = Parqry: .Update
End With
End If
rst.Close: Set dbs = Nothing
End Sub[/code]
Comment