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

Guardar detalle

Estas en el tema de Guardar detalle en el foro de Visual Basic clásico en Foros del Web. Buenos dias con todos los miembros...tengo un problema para guardar los detalles de una factura... mi codigo es el sgte: 'Validacion de los Campos Principales ...
  #1 (permalink)  
Antiguo 25/09/2006, 10:38
 
Fecha de Ingreso: septiembre-2006
Mensajes: 2
Antigüedad: 18 años, 7 meses
Puntos: 0
Mensaje Guardar detalle

Buenos dias con todos los miembros...tengo un problema para guardar los detalles de una factura... mi codigo es el sgte:

'Validacion de los Campos Principales
If txt_Cliente = "" Then
MsgBox "Ingrese Cliente", vbInformation, "AVISO"
txt_Cliente.SetFocus
ElseIf txt_Direccion = "" Then
MsgBox "Ingrese Direccion", vbInformation, "AVISO"
txt_Direccion.SetFocus
ElseIf txt_Ruc = "" Then
MsgBox "Ingrese RUC del Cliente", vbInformation, "AVISO"
txt_Ruc.SetFocus
ElseIf txt_Orden_de_Compra = "" Then
MsgBox "Ingrese Orden De Compras", vbInformation, "AVISO"
txt_Orden_de_Compra.SetFocus
ElseIf txt_Guia_de_Remision = "" Then
MsgBox "Ingrese Guia de Remision", vbInformation, "AVISO"
txt_Guia_de_Remision.SetFocus
ElseIf txt_Total = "" Then
If txt_Cantidad = "" Then
MsgBox "Ingrese Cantidad", vbInformation, "AVISO"
txt_Cantidad.SetFocus
ElseIf txt_Importe = "" Then
MsgBox "Ingrese Importe", vbInformation, "AVISO"
txt_Importe.SetFocus
ElseIf txt_Descripcion = "" Then
MsgBox "Ingrese Descripción", vbInformation, "AVISO"
txt_Descripcion.SetFocus
End If
Else
'Busca y Guarda a un cliente nuevo
rscliente.MoveFirst
rscliente.Find "Cliente_Nombre='" + txt_Cliente + "'"
If rscliente.EOF Then
rscliente.MoveLast
rscliente.AddNew
rscliente!Cliente_Nombre = txt_Cliente
rscliente!Cliente_Direccion = txt_Direccion
rscliente!Cliente_Ruc = txt_Ruc
rscliente.Update
rscliente.Requery
'Guarda La factura
rsfact.MoveLast
rsfact.AddNew
rsfact!Num_Factura = lbl_Factura
rsfact!Cliente_Nombre = txt_Cliente


rsfact!Fec_Emision = Dt_Fecha
rsfact!Ord_Compra = txt_Orden_de_Compra
rsfact!Guia_Remision = txt_Guia_de_Remision
rsfact!Valor_Letras = txt_Letras
rsfact!Sub_total = txt_Subtotal
rsfact!Igv = txt_Igv
rsfact!Total = txt_Total
rsfact.Update
rsfact.Requery

'Guarda los Detalles de la Factura
ultimo = rsdetalle.RecordCount-1
' rsdetalle.MoveFirst
For i = 0 To ultimo

rsdetalle.Move (i)

MsgBox ("Posicion Actual " & (rsdetalle.AbsolutePosition))
rsfactdetalle.MoveLast
MsgBox ("Numero de Factura " & rsfactdetalle!Num_Factura)
rsfactdetalle.AddNew
rsfactdetalle!Num_Factura = rsdetalle!detalle
MsgBox ("Numero de Factura " & rsfactdetalle!Num_Factura)
rsfactdetalle!Cantidad = rsdetalle!Cantidad
MsgBox ("Cantidad" & rsfactdetalle!Cantidad)
rsfactdetalle!Descripcion = rsdetalle!Descripcion
MsgBox ("Descripcion " & rsfactdetalle!Descripcion)
rsfactdetalle!Importe = rsdetalle!Importe
MsgBox ("Importe " & rsfactdetalle!Importe)
rsfactdetalle!Valor_Venta = rsdetalle!Venta
MsgBox ("Venta " & rsfactdetalle!Valor_Venta)
rsfactdetalle.Update
rsfactdetalle.Requery



Next







Else
'Adiciona un registro si no hay registros
If rsfact.RecordCount = 0 Then
rsfact.AddNew
Else ' Adiciona un Registro si hay uno o mas registros
rsfact.MoveLast
rsfact.AddNew
End If
'Guarda las Facturas
rsfact!Num_Factura = lbl_Factura
rsfact!Cliente_Nombre = txt_Cliente

rsfact!Fec_Emision = Dt_Fecha
rsfact!Ord_Compra = txt_Orden_de_Compra
rsfact!Guia_Remision = txt_Guia_de_Remision
rsfact!Valor_Letras = txt_Letras
rsfact!Sub_total = txt_Subtotal
rsfact!Igv = txt_Igv
rsfact!Total = txt_Total
rsfact.Update
rsfact.Requery

' Guarda Los detalles de las facturas
ultimo = rsdetalle.RecordCount - 1
rsdetalle.MoveFirst
For i = 0 To ultimo

rsdetalle.Move (i)

MsgBox ("Posicion Actual " & rsdetalle.AbsolutePosition)
MsgBox (rsdetalle!Cantidad)
rsfactdetalle.AddNew
rsfactdetalle!Num_Factura = rsdetalle!detalle
rsfactdetalle!Cantidad = rsdetalle!Cantidad
rsfactdetalle!Descripcion = rsdetalle!Descripcion
rsfactdetalle!Importe = rsdetalle!Importe
rsfactdetalle!Valor_Venta = rsdetalle!Venta
rsfactdetalle.Update
rsfactdetalle.Requery




Next

End If
END SUB



ahora el problema es que cuando ingreso 2 detalles de la misma factura normal las almaceno en la BD pero cuando ingreso 3 detalles al momento de almacenar el tercer detalle me arroja q la posicion del registro es de -3 y me pide un registro nuevo pero si deseo almacenar 4 o mas = no me almacena el tercer registro sino que se pasa al sigte registro....y al final regresa al tercer registro y no lo guarda....

haber si pueden revisan mi codigo ps....y si me pueden ayudar se los agradeceria bastante...por siacaso el rsdetalle es un recordset temporal, porque stoy usando un datagrid
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 14:34.