
Problemas con RecordSet Access
Publicado por CarlosR (2 intervenciones) el 03/10/2013 20:03:49
Buenos días. Saludos a todos. Mi caso es el siguiente. Tengo un formulario en Access y cuando ingreso un NumSerie; quiero hacer una búsqueda del mismo en la tabla ORDENES; si se encuentra el registro presentar en el mismo formulario, la ultima vez que fue introducido y su fecha. Este numserie puede ser introducido varias veces.
La cosa es que siempre me manda error 3265 - no se encuentra el elemento en esta colección. Esto solo pasa cuando encuentra el registro. Saludos desde Panamá y agradezco toda su ayuda.
+++ ES AQUI DONDE MANDA EL ERROR +++
AntCntInt = rst!Fields("Crt_Interno").Value
Aqui esta mi codigo
La cosa es que siempre me manda error 3265 - no se encuentra el elemento en esta colección. Esto solo pasa cuando encuentra el registro. Saludos desde Panamá y agradezco toda su ayuda.
+++ ES AQUI DONDE MANDA EL ERROR +++
AntCntInt = rst!Fields("Crt_Interno").Value
Aqui esta mi codigo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Private Sub Num_Serie_LostFocus()
Dim Nserie As String 'recibe valor de NvaSerie'
Dim AntCntInt As Integer 'Recibe el valor de la orden anterior'
Dim AntFecha As Date 'Recibe el valor de la fecha anterior'
Dim CadenaSql As String
Dim db As Database
Dim rst As Recordset
'Captura el valor de la Nva Serie Introducida'
Nserie = StrConv(Me.Num_Serie, 1)
Set db = CurrentDb()
'CadenaSql = ("Select Crt_Interno, Fecha_Ingreso From ORDENES Where ORDENES.Num_Serie = 'Forms!DEPSA_ORDENES!Num_Serie'")
CadenaSql = ("Select Num_Serie From ORDENES Where ORDENES.Num_Serie = '" & Nserie & "'")
Set rst = db.OpenRecordset(CadenaSql)
Do While Not rst.EOF
rst.MoveFirst
'rst.MoveLast
Forms!DEPSA_ORDENES!Orden_Anterior = ""
Forms!DEPSA_ORDENES!Fecha_RepAnt = ""
If rst!Num_Serie = Forms!DEPSA_ORDENES!Num_Serie Then
MsgBox "Valor existe y nva serie es: " & Nserie
AntCntInt = rst!Fields("Crt_Interno").Value
AntFecha = rst!Fields("Fecha_Ingreso").Value
Forms!DEPSA_ORDENES!Orden_Anterior = AntCntInt
Forms!DEPSA_ORDENES!Fecha_RepAnt = AntFecha
End If
rst.MoveNext
'rst.MovePrevious
Loop
rst.Close
Set rst = Nothing
End Sub
Valora esta pregunta


0