Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Beginner
Aug 6, 1997

Fix For Data Control Error 3426

This code, which works fine under VB3, may generate runtime error 3426--"The action was canceled by an associated object"--in the 16-bit version of VB4:
 Private Sub cmdUpdate_Click()
	' Save contents of bound controls
	' to underlying recordset
	datCtl.Recordset.Update
End Sub
The problem seems to occur because the 16-bit version of VB4, unlike VB3, does not perform an implicit Edit method when the Data control moves to a new record. The solution is to check the record set's EditMode and perform an explicit Edit method if necessary:
 Private Sub cmdUpdate_Click()
	If datCtl.Recordset.EditMode = dbEditNone Then
		datCtl.Recordset.Edit
	End If
	datCtl.Recordset.Update
End Sub
Another workaround is to replace the Update method with the Data control's UpdateRecord method, which is equivalent functionally to performing an Edit followed by an Update. The drawback is that UpdateRecord does not fire a Validate event, so don't use it if you rely on that event to perform data validation.
Phil Weber
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date