By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,255 Members | 2,717 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,255 IT Pros & Developers. It's quick & easy.

Handling Errors

P: 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
Share this Question
Share on Google+
5 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
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

P: 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
Expert Mod 10K+
P: 14,534
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

P: 9
Well, thanks for your help Mary.

This site its great!
Dec 21 '06 #5

MMcCarthy
Expert Mod 10K+
P: 14,534
Well, thanks for your help Mary.

This site its great!
You're welcome

Merry Christmas

Mary
Dec 21 '06 #6

Post your reply

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