ADO AddNew Error 3219

G

Guest

Hello folks, I am wondering of anyone could help me out here.

I have a database I am building for a project with two tables . One table is
read-only, and linked to another database. The other table's data is
generated from data added to a form based on the data on the read-only tabel.
The problem is, when I run the sub, the record is not being added to the
second table.

Any suggestions?

'Update the records to the tblAHD table
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset

With rst
.ActiveConnection = CurrentProject.Connection
.CursorType = adOpenKeyset
.LockType = adLockPessimistic
.Open "Select * from tblAHD where SessionID = 'Session'"
.AddNew
!SessionID = Me.txtAHDSession
!DateClosed = Now()
!Processor = Me.cmbAHDEmployees
!Dispute1Result = Me.cmbDispute1Results
!Dispute2Result = Me.cmbDispute2Results
!Dispute3Result = Me.cmbDispute3Results

End With

rst.Close
Set rst = Nothing

Exit Sub
 
R

RoyVidar

Leo said:
Hello folks, I am wondering of anyone could help me out here.

I have a database I am building for a project with two tables . One table is
read-only, and linked to another database. The other table's data is
generated from data added to a form based on the data on the read-only tabel.
The problem is, when I run the sub, the record is not being added to the
second table.

Any suggestions?

'Update the records to the tblAHD table
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset

With rst
.ActiveConnection = CurrentProject.Connection
.CursorType = adOpenKeyset
.LockType = adLockPessimistic
.Open "Select * from tblAHD where SessionID = 'Session'"
.AddNew
!SessionID = Me.txtAHDSession
!DateClosed = Now()
!Processor = Me.cmbAHDEmployees
!Dispute1Result = Me.cmbDispute1Results
!Dispute2Result = Me.cmbDispute2Results
!Dispute3Result = Me.cmbDispute3Results

End With

rst.Close
Set rst = Nothing

Exit Sub

You have unsaved changes to the recordset. Try issuing a issuing an

..update

before you close the recordset
 
G

Guest

Thanks Roy. I added the ".Update," and it works like a charm. A simple
mistake... What I get for trying to code while watching football and the ALDS
at teh same time .
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top