AddNew Error

N

NevilleT

This code has worked perfectly for years and now suddenly causes an error at
the rst!AddNew line.

3251 Operation is not supported for this type of object.

I can probably replace it with an SQL Update but curious as to what is
causing the problem. Program is Access 2000 and the error is on both an
Access back end and SQL Server back end.

Not sure it is relevant but references are:
Visual basic for Application
Microsoft Access 11.0 Object Library
Microsoft DAO 3.6 Object Library
OLE Automation
Microsoft Outlook 12.0 Object Library
Microsoft Project 9.0 Object Library

Public Sub subNewName(NewPerson As String, Reply As Integer)
' If a name is not in a drop down list, prompt to add the name to the
table
Dim intAnswer As Integer
Dim dbs As Database
Dim rst As dao.Recordset
Dim oaQry As String
Dim bolForm As Boolean

On Error GoTo Error_subNewName

'If allowed to update, ask do you want to add a name
intAnswer = MsgBox("Add " & NewPerson & " to the list of Names?",
vbQuestion + vbYesNo)

'If they do want to add a name, display the frmPeople form and
add the name to the form
If intAnswer = vbYes Then
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblPeople", dbOpenSnapshot,
dbSeeChanges)
rst.AddNew
rst!Name = NewPerson
rst!Active = True
rst.Update
Reply = acDataErrAdded ' Requery the combo box list.

strFormName = "frmPeople"
strLinkCriteria = NewPerson
DoCmd.OpenForm strFormName, , , , , , strLinkCriteria
End If

If intAnswer = vbNo Then
Exit Sub
End If

Exit_subNewName:
rst.Close
Exit Sub

Error_subNewName:
MsgBox "Error in subNewName: " & Err.Number & " - " & Err.Description
GoTo Exit_subNewName

End Sub
 
N

NevilleT

Thanks Alex. That worked. I am still curious as to why it worked for years
before it suddenly started causing an error.
 

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