September 10th, 2010, 12:05 AM
Error handling using ADO 2.0
I have a fear to good understanding of Using Visual Basic 6.0 Codes.
Im using code to create ADO Cmdobjects & RecordSets to connect and handle records in an Access 2003 mdb. In the Accounts table, I have indexed the field Name property to Yes (No Duplicates).
I using the following code inside the BtnSave botton to trap duplication error:
Private Sub CmdGuardar_Click()
' guardar modificaciones y nuevos registros cuentas
On error goto Trap
If Valida = False Then Exit Sub
If LblMODE.Caption = "Aņadir Indicadores" Then Ctas.AddNew
MsgBox "Duplicate entry", vbCritical, "Error Information"
I'm traping the error, but need extra code the prevent a couple of issues:
1- The Datagrid is still been populated with the new entry.
2- I have tried CtasCancel, CtasCancelUpdate but nothing seens to help clering the error
completely, messages like "Update was canceled", "To prevent duplicate entries
change field name property etc
3- Upon closing the form using unload botton and including code to close the table as well
as follows: Ctas.Close, I getting another error message "Operation is not allowed in this
I'm using a MDI form from wich I connect to the Access Database, and only open tables as needed in the forms.
Do not know what I'm doing wrong, any one out there with any sudgestions, thank you
in advance for any help provided.
September 10th, 2010, 12:38 AM
Re: Error handling using ADO 2.0
If you are BINDING the table, it won't allow duplicates (if you've set that up correctly)
You could use code to load the tables. See this article.
Tags for this Thread
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!