¿Cómo simplificar código? Necesito que me ayuden a simplificar el siguiente código, por favor.
If frmFacturacion.ms.TextMatrix(1, 10) <> Empty Then
rsDatos.AddNew
rsDatos.Fields("NumFactura") = frmNumeroFactura.Text1
rsDatos.Fields("FechaFactura") = frmFacturacion.Label4
rsDatos.Fields("Rut") = frmFacturacion.Text2
rsDatos.Fields("Vendedor") = frmFacturacion.dtcVend
rsDatos.Fields("OrdenCompra") = frmFacturacion.Text1
rsDatos.Fields("Codigo") = frmFacturacion.ms.TextMatrix(1, 10)
rsDatos.Fields("Cantidad") = frmFacturacion.ms.TextMatrix(1, 0)
rsDatos.Fields("Precio") = frmFacturacion.ms.TextMatrix(1, 5)
rsDatos.Fields("Neto") = frmFacturacion.ms.TextMatrix(1, 6)
rsDatos.Fields("Iva") = frmFacturacion.ms.TextMatrix(1, 7)
rsDatos.Fields("Retencion") = frmFacturacion.ms.TextMatrix(1, 8)
rsDatos.Fields("Ila") = frmFacturacion.ms.TextMatrix(1, 9)
rsDatos.Fields("Total") = (Val(frmFacturacion.ms.TextMatrix(1, 6)) + Val(frmFacturacion.ms.TextMatrix(1, 7)) + Val(frmFacturacion.ms.TextMatrix(1, 8)) + Val(frmFacturacion.ms.TextMatrix(1, 9)))
rsDatos.Fields("CondVenta") = frmFacturacion.DataCombo1
rsDatos.Fields("ListaPrecio") = frmFacturacion.DataCombo2
rsDatos.Fields("Destino") = frmFacturacion.Label19
rsDatos.Fields("Observaciones") = frmFacturacion.Label20
rsDatos.Fields("Usuario") = frmFacturacion.Label21
rsDatos.Update
End If
If frmFacturacion.ms.TextMatrix(2, 10) <> Empty Then
rsDatos.AddNew
rsDatos.Fields("NumFactura") = frmNumeroFactura.Text1
rsDatos.Fields("FechaFactura") = frmFacturacion.Label4
rsDatos.Fields("Rut") = frmFacturacion.Text2
rsDatos.Fields("Vendedor") = frmFacturacion.dtcVend
rsDatos.Fields("OrdenCompra") = frmFacturacion.Text1
rsDatos.Fields("Codigo") = frmFacturacion.ms.TextMatrix(2, 10)
rsDatos.Fields("Cantidad") = frmFacturacion.ms.TextMatrix(2, 0)
rsDatos.Fields("Precio") = frmFacturacion.ms.TextMatrix(2, 5)
rsDatos.Fields("Neto") = frmFacturacion.ms.TextMatrix(2, 6)
rsDatos.Fields("Iva") = frmFacturacion.ms.TextMatrix(2, 7)
rsDatos.Fields("Retencion") = frmFacturacion.ms.TextMatrix(2, 8)
rsDatos.Fields("Ila") = frmFacturacion.ms.TextMatrix(2, 9)
rsDatos.Fields("Total") = (Val(frmFacturacion.ms.TextMatrix(2, 6)) + Val(frmFacturacion.ms.TextMatrix(2, 7)) + Val(frmFacturacion.ms.TextMatrix(2, 8)) + Val(frmFacturacion.ms.TextMatrix(2, 9)))
rsDatos.Fields("CondVenta") = frmFacturacion.DataCombo1
rsDatos.Fields("ListaPrecio") = frmFacturacion.DataCombo2
rsDatos.Fields("Destino") = frmFacturacion.Label19
rsDatos.Fields("Observaciones") = frmFacturacion.Label20
rsDatos.Fields("Usuario") = frmFacturacion.Label21
rsDatos.Update
End If
If frmFacturacion.ms.TextMatrix(3, 10) <> Empty Then
rsDatos.AddNew
rsDatos.Fields("NumFactura") = frmNumeroFactura.Text1
rsDatos.Fields("FechaFactura") = frmFacturacion.Label4
rsDatos.Fields("Rut") = frmFacturacion.Text2
rsDatos.Fields("Vendedor") = frmFacturacion.dtcVend
rsDatos.Fields("OrdenCompra") = frmFacturacion.Text1
rsDatos.Fields("Codigo") = frmFacturacion.ms.TextMatrix(3, 10)
rsDatos.Fields("Cantidad") = frmFacturacion.ms.TextMatrix(3, 0)
rsDatos.Fields("Precio") = frmFacturacion.ms.TextMatrix(3, 5)
rsDatos.Fields("Neto") = frmFacturacion.ms.TextMatrix(3, 6)
rsDatos.Fields("Iva") = frmFacturacion.ms.TextMatrix(3, 7)
rsDatos.Fields("Retencion") = frmFacturacion.ms.TextMatrix(3, 8)
rsDatos.Fields("Ila") = frmFacturacion.ms.TextMatrix(3, 9)
rsDatos.Fields("Total") = (Val(frmFacturacion.ms.TextMatrix(3, 6)) + Val(frmFacturacion.ms.TextMatrix(3, 7)) + Val(frmFacturacion.ms.TextMatrix(3, 8)) + Val(frmFacturacion.ms.TextMatrix(3, 9)))
rsDatos.Fields("CondVenta") = frmFacturacion.DataCombo1
rsDatos.Fields("ListaPrecio") = frmFacturacion.DataCombo2
rsDatos.Fields("Destino") = frmFacturacion.Label19
rsDatos.Fields("Observaciones") = frmFacturacion.Label20
rsDatos.Fields("Usuario") = frmFacturacion.Label21
rsDatos.Update
End If
Esto lo tengo que hacer 15 veces, lo que sucede es que no se como guardar los datos de los 15 row que tengo en un flex grid, con los datos de los label, textbox, etc.
Desde ya, gracias |