473,387 Members | 1,588 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Handling Errors

9
Hi, im working with Access 2002 and im having some troubles with errors.
I have a form, so i can record data in a table called "Consumibles", but i wanted my own form to do this task, so i made a form with 6 text box, 1 combo box and one button.

The thing is that i dont know why some errors appears, the numbers of these errors are -2147467259 and 0. Could you please help me? What is causing this error and what can i do to solve this situation?

The code of the button in the Click event is:

Private Sub cmdAceptar_Click()
On Error GoTo Error:
Dim Conexion As New ADODB.Connection
Dim Catalogo As New ADOX.Catalog
Dim ConjuntoRegistros As New ADODB.Recordset
Conexion.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.CurrentProject.Path & "\Control de Herramientas.mdb"
Set Catalogo.ActiveConnection = Conexion
ConjuntoRegistros.Open "Consumibles", Catalogo.ActiveConnection, adOpenDynamic, adLockOptimistic
ConjuntoRegistros.Fields.Refresh
ConjuntoRegistros.AddNew
For Each Campo In ConjuntoRegistros.Fields
If (Campo.Name = "Codigo") Then
valor = txtCodigo
Campo.Value = UCase$(valor)
ElseIf (Campo.Name = "Descripcion") Then
valor = cmbDescripcion
Campo.Value = valor
ElseIf (Campo.Name = "CodigoProveedor") Then
valor = txtProveedor
Campo.Value = Val(valor)
ElseIf (Campo.Name = "Localizacion") Then
valor = txtLocalizacion
Campo.Value = valor
ElseIf (Campo.Name = "PuntoReorden") Then
valor = txtPuntoReorden
Campo.Value = valor
ElseIf (Campo.Name = "Precio") Then
valor = txtPrecio
Campo.Value = Val(valor)
ElseIf (Campo.Name = "Cantidad") Then
valor = txtCantidad
Campo.Value = Val(valor)
ElseIf (Campo.Name = "Total") Then
valor = Val(txtCantidad) * Val(txtPrecio)
Campo.Value = Val(valor)
End If
Next
ConjuntoRegistros.Update
ConjuntoRegistros.Close
Set ConjuntoRegistros = Nothing
Set Catalogo = Nothing
Conexion.Close
Set Conexion = Nothing
MsgBox "Se dio de alta la herramienta con código " & txtCodigo, vbDefaultButton1, "OK"
txtCodigo = ""
txtProveedor = ""
txtCantidad = ""
txtPrecio = ""
txtLocalizacion = ""
txtPuntoReorden = ""

Error:
If Err.Number = 94 Then
MsgBox "Make sure all data has been provided", vbCritical, "Error"
ElseIf Err.Number = -2147217887 Then
MsgBox "The code of the tool has already been registered", vbCritical, "Error"
ElseIf Err.Number = -2147352571 Then
MsgBox "Enter invalid data in numerical fields", vbCritical, "Error"
Else
MsgBox "Error" & Err.Number
End If

End Sub
Dec 20 '06 #1
5 1563
MMcCarthy
14,534 Expert Mod 8TB
Can you tell us exactly which lines are causing the errors. If you click on Debug when the error appears it should go to the code and highlight the line in yellow.

Mary
Dec 21 '06 #2
oc20
9
The thing is that the error only appears when it wants to . . . i know this sound strange but thats what is happening.
Dec 21 '06 #3
MMcCarthy
14,534 Expert Mod 8TB
The thing is that the error only appears when it wants to . . . i know this sound strange but thats what is happening.
Unfortunately unless we know where the error is appearing and under what circumstances theres not much we can do. Unless someone gets inspired?

You could try changing your code to DAO as it works better (in my opinion) with the Jet Engine and is easier to code.

Mary
Dec 21 '06 #4
oc20
9
Well, thanks for your help Mary.

This site its great!
Dec 21 '06 #5
MMcCarthy
14,534 Expert Mod 8TB
Well, thanks for your help Mary.

This site its great!
You're welcome

Merry Christmas

Mary
Dec 21 '06 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: damjanu | last post by:
Dear All; I have 3 issues 1) On some of my tables I have unique indexes, so that for example no two phone numbers can be the same. When user enters phone number that already exists, a scary...
2
by: TJoker .NET | last post by:
Hi all. I'm writing some .net compoents that are also going to be used from vb6 code. Is there a way for me to distinguish all the different types of exceptions that the .net code my throw ? My...
2
by: UJ | last post by:
What do most people do to handle errors from the DB? How about errors in general. It would be nice to have a cleaner page than the code dump you get from .Net. I see that in web.config you can...
0
by: Suhas Vengilat | last post by:
Hi, I am working on an ASP.Net (2.0) application with SQL 2K5. We need to display customised error messages for both business validation errors from the C# components as well as from the data...
2
by: Kevin Frey | last post by:
One of my chief criticisms of validators in an ASP.NET page is that they can result in a developer re-implementing much of the "business logic" of a transaction at the page level. Assuming we...
8
by: RichardOnRails | last post by:
I have a Stack class that works fine. In particular, when it encounters an error, it cout's a msg and exits. However, I'd like to change it to report the error and continue with dummy data as...
0
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Hi misters, I have an application web ASP.NET 2.0 using ASP.NET AJAX and Ajax Control Toolkit. We need handles errors of AJAX, and I want have only one method that handles those errors (like...
8
by: Rahul | last post by:
Hi Everyone, I'm currently developing a class for a database, each object of the class will establish a connection to the database on a remote server and and all of this happens on the...
0
by: mirandacascade | last post by:
Questions toward the bottom of the post. Situation is this: 1) Access 97 2) SQL Server 2000 3) The Access app: a) sets up pass-thru query b) .SQL property of querydef is a string, the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.