Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error 3426 on AddNew

Status
Not open for further replies.

Navel12

Programmer
Feb 21, 2003
17
US
I am using a bound data control from VB6 SP5 that is linked to an Access 2000 table. I am trying to add a new student record using the following code:

stdDisp.student.Recordset.AddNew
stdDisp.student.Recordset.Edit
stdDisp.student.Recordset!ID = Val(stud_id$)
stdDisp.student.Recordset!lname = lastname$
stdDisp.student.Recordset!fname = firstname$
stdDisp.student.Recordset!m_init = ""
stdDisp.student.Recordset!cur_grade = curgrade
stdDisp.student.Recordset!bdate = bdate$
stdDisp.student.Recordset!mfsex = sex$
stdDisp.student.Recordset!ethnic = ethnic$
stdDisp.student.Recordset.Update

I am getting a error 3426. This code had been working up until recently. Nothing has changed that I am aware of. I have searched the forums and tried to place an Edit command before the update but still have the error.

Any suggestions????
 
It appears this error is present for VB4. I am running VB6. The odd thing is that this has worked for two years and suddenly this error appears. Is there some other setting that I am missing. I have check Microsoft and tried an explicit test for EOF and BOF but am still getting the error. This is extremely frustrating. Any suggestions would be welcome!!!!
 
I have read MS Knowledge base and tried their workaround. I continue to get the same error. I can do an AddNew and Update on a different table in the same manner, just not this one table. This is why I can't seem to figure out if it's a setting or what else would cause this error.
 
Verify that table can is updatable within Access. Is it a linked table or local?

"I think we're all Bozos on this bus!" - Firesign Theatre [jester]
 
It is a linked table that I can add records to directly through Access. I am just not able to Add from within the application.
 
It appears the problem is at RecordSet.Edit You should not .edit when using .AddNew
Also, .edit is not needing when using ADO
 
Thanks for the reply:

I placed the Edit in as a workaround suggested from MS knowledge base. It was not there originally. With or without I still get the 3426 error.
 
Are you using DAO or ADO?

I found this in the MSDN help for VB (by searching for 3426). It may be relevent:

PRB This Action was Cancelled by an Associated Object.(3426)"
ID: Q189851



--------------------------------------------------------------------------------
The information in this article applies to:

Microsoft Visual Basic Learning, Professional, and Enterprise Editions for Windows, versions 5.0, 6.0
Microsoft Visual Basic Standard, Professional, and Enterprise Editions, 16-bit and 32-bit, for Windows, version 4.0

--------------------------------------------------------------------------------


SYMPTOMS
This article discusses the error message "This action was cancelled by an associated object." that Visual Basic generates when working with Access databases and the Data control. This article does not apply to the ADO data control.



CAUSE
This error is being generated because the AddNew command of a bound recordset causes Visual Basic to try to save the current record if the data has changed. Because the data control is currently pointing to a NULL record and not an empty record, the data cannot be saved so the "action was cancelled by an associated object" error is reported. This is commonly seen when using the data form wizard in Visual Basic versions 4.0 and 5.0. The data form wizard in Visual Basic 6.0 generates code for the ADO data control so this error is less likely to occur.



RESOLUTION
Check the underlying recordset to see if either the BOF or EOF properties are True before allowing an implicit save to occur. An implicit save occurs either when using the data control to navigate off of a record where the information has changed or adding a record to a bound recordset.




"I think we're all Bozos on this bus!" - Firesign Theatre [jester]
 
ArtieChoke

I am using a DAO recordset. The odd thing is that this error is only occuring on one of the 5 tables I am adding to. If I skip this code and use AddNew on another table in the database the AddNew works fine.

In response to the article, I did see that and tried a test for BOF and EOF but it was no help.

I am by no means a VB or Access expert but this is becoming extrememly frustrating!!
 
I have done additional searching and found that AddNew works in an older version of my code. The code is doing the exact same thing. Does any one know what setting could be changed that would cause error 3426 to occur. Please help!!
 
If I skip this code and use AddNew on another table in the database the AddNew works fine.

If the code works on another table, then I would surmise that the error is caused by a data problem. It could be caused by a violation of the primary key (if one exists), trying to insert an ID in an Autonumber column, or even a type mismatch condition (trying to insert a wrong data type).

I'd suggest examining the schema of the table against the data you're trying to add and see if any of these conditions exist when the error occurs.


Mark

"You guys pair up in groups of three, then line up in a circle."
- Bill Peterson, a Florida State football coach
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top