Foros del Web » Programación para mayores de 30 ;) » Programación General » Visual Basic clásico »

Error 3021 en tiempo de ejecución

Estas en el tema de Error 3021 en tiempo de ejecución en el foro de Visual Basic clásico en Foros del Web. Buenas Tardes, trato de hacer un simple sistemita que me guarde una serie de datos numericos, pero cuando lo ejecuto me da el dgte error: ...
  #1 (permalink)  
Antiguo 12/12/2007, 15:25
 
Fecha de Ingreso: diciembre-2007
Mensajes: 2
Antigüedad: 16 años, 4 meses
Puntos: 0
Exclamación Error 3021 en tiempo de ejecución

Buenas Tardes, trato de hacer un simple sistemita que me guarde una serie de datos numericos, pero cuando lo ejecuto me da el dgte error:

el codigo es el sgte:


Option Explicit

Dim cnn As New ADODB.Connection
Dim rs As New ADODB.Recordset

'Connection Confirmation
Private Sub Form_Load()


' establece la cadena de conexión a utilizar en la propiedad ConnectionString
cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
App.Path & "\bdok.mdb" & ";Persist Security Info=False"

' abre la base de datos
cnn.Open

' Abre el recordset enviando la consulta sql
rs.Open "Select * from factores", cnn, adOpenDynamic, adLockOptimistic

' muestra los datos en los text
Call Visualizar_Datos
End Sub


'''''''''''''''''''''''''''''''''''''''''''''''
Private Sub cmdMoveFirst_Click()

rs.MoveFirst

' Visualiza los datos en los textbox
Call Visualizar_Datos
End Sub


'''''''''''''''''''''''''''''''''''''''''''''''
Private Sub cmdMoveLast_Click()

' Ejecuta MoveLast y se posiciona en el último registro
rs.MoveLast

' Visualiza los datos en los textbox
Call Visualizar_Datos
End Sub


'''''''''''''''''''''''''''''''''''''''''''''
Private Sub cmdMoveNext_Click()

rs.MoveNext

' Si no sobrepasó el final del recordset ...
If rs.EOF Then
' se posiciona en el ultimo
rs.MoveLast
MsgBox " Se está en el ultimo registro ", vbInformation
Else
' Visualiza los datos en los text box
Call Visualizar_Datos
End If
End Sub



'''''''''''''''''''''''''''''''''''''''''''''''''' ''''
Private Sub cmdMovePrevious_Click()
rs.MovePrevious

' si el recordset sobrepasó el comienzo se posiciona en el primero
If rs.BOF Then
rs.MoveFirst
MsgBox " este es el Primer registro ", vbInformation, " Primer registro"
Else
' Carga los datos
Call Visualizar_Datos
End If
End Sub



'''''''''''''''''''''''''''''''''''''''''''''''''' '''''
Private Sub cmdAddNew_Click()

Call clear
' Ejecuta el método AddNew para crear un registro
rs.AddNew
' Le pasa el foco al control
Text2.SetFocus
Frame2.Enabled = False
End Sub


'''''''''''''''''''''''''''''''''''''''''''''''''' ''''
Private Sub cmdDelete_click()

If MsgBox(" Eliminar el registro ?? ", vbOKCancel + vbExclamation, " Eliminar ") = vbOK Then

' elimina el registro en el que está posicionado el recordset
rs.Delete

' Mueve al siguiente
rs.MoveNext

' si elrecordset llegó al final se posiciona en el último
If rs.EOF Then
rs.MoveLast
MsgBox " Ultimo registro ", vbInformation
End If

' muestra los datos en los textbox
Call Visualizar_Datos
End If

Frame2.Enabled = True

End Sub


'''''''''''''''''''''''''''''''''''''''
Private Sub cmdSave_Click()
If Text2 = "" Or Text3 = "" Then
MsgBox "Debe completar los datos", vbExclamation
Exit Sub
End If
Call Asignar_Datos
rs.Update
MsgBox " Registro guardado", vbInformation, "Grabar"
Frame2.Enabled = True
End Sub



'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''
Private Sub Visualizar_Datos()
Text1.Text = CLng(rs("Id")) ----->[ en esta linea me arroja error:3021!!!
Text2.Text = rs("temperatura")
Text3.Text = rs("humedad")
Text4.Text = rs("viento")
Text5.Text = rs("presion")
Text6.Text = rs("rocio")
Text7.Text = rs("calor")
Text8.Text = rs("aire")
Text9.Text = rs("responsable")
End Sub

' Limpia las cajas de texto
Private Sub clear()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
End Sub

' Sub que asigna los datos al recordset
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''
Private Sub Asignar_Datos()
rs("temperatura") = Text2.Text
rs("Humedad") = Text3.Text
rs("Viento") = Text4.Text
rs("Presion") = Text5.Text
rs("Rocio") = Text6.Text
rs("Calor") = Text7.Text
rs("Aire") = Text8.Text
rs("Responsable") = Text9.Text

End Sub

Ya he probado todo lo que he creido que puede ser, no soy experta en e area pero deseo aprender, si alguien me puede ayudar a lograr ejecutar este pgma, mucho le agradeceria, muchas gracias.
  #2 (permalink)  
Antiguo 12/12/2007, 15:48
 
Fecha de Ingreso: mayo-2005
Mensajes: 117
Antigüedad: 19 años
Puntos: 0
Re: Error 3021 en tiempo de ejecución

cheka este post espero te sirva..

http://www.forosdelweb.com/f69/error-3021-a-538749/

ahi me cuentas como te fue ...


.........Rahd RR
  #3 (permalink)  
Antiguo 13/12/2007, 15:38
 
Fecha de Ingreso: diciembre-2007
Mensajes: 2
Antigüedad: 16 años, 4 meses
Puntos: 0
help me!

Hola rahd gracias x tu interes, ese link ya lo habia visto e intente de varias formas modificar mi codigo tomando en cuenta esa explicacion pero honestamente estoy trancada, no veo el error en las lineas de codigo q publique....por eso acudo a uds expertos en el area me puedan ayudar a ver en que linea estoy errada...
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 15:42.