Ver Mensaje Individual
  #3 (permalink)  
Antiguo 25/02/2010, 01:40
fmcampos
 
Fecha de Ingreso: abril-2005
Mensajes: 42
Antigüedad: 19 años
Puntos: 0
Respuesta: Insertar campos en un Form de forma dinamica

Te envio el codigo, lo que quiero hacer es mostrar coger datos una una consulta realizar calculos con ellos y mostarlos, y el problema esta en que no se cuantos datos tengo. Es para un control de entrada y tengo parejas de entrada salida y tengo que hacer calculos con estas parejas. El cofigo que tengo:
Código:
Private Sub Form_Load()

Dim rst As DAO.Recordset
Dim rst_next As DAO.Recordset
Dim E_fecha_flag, V_total, V_parcial, V_aux, C_par, C_Elem, C_lineas, X As Integer
'Variables de impresion en formaulario
Dim Etiquetas As Label



'<------------ Configuración de Form para eso   ----------------------->
 With Form_Form1
    .Caption = "Prueba"
    .Width = 400
    .NavigationButtons = False
    .RecordSelectors = False
 
 End With

'<------------ Fin Configuración de Form para eso   ----------------------->


Set rst = CurrentDb.QueryDefs("Emitir_usuario").OpenRecordset()
Set rst_next = CurrentDb.QueryDefs("Emitir_usuario").OpenRecordset()

'Avanzamos una posición el puntero auxiliar
If Not rst_next.EOF Then
    rst_next.MoveNext
End If

'Empezamos a pintar elementos

E_fecha_flag = 0
V_total = 0

While Not rst.EOF
    
    'Comprobas que la fecha que tenemos es correcta
If E_fecha_flag = 0 Then
        
        'Escribir fecha en el Form la fecha rst(4)
        E_fecha_flag = 1
        V_parcial = 0
     End If
    
    'Escribimos el tipo si es Entrada o salida rst(3)
    'Escribimos la hora que sea rst(5)
    
    If rst(4) = rst_next(4) Then
        If rst(3) <> rst_next(3) Then
          V_aux = 0
          V_aux = rst_next(3) - rst(3)
          V_parcial = V_parcial + V_aux
          V_total = V_total + V_aux
       Else
           V_parcial = 0
           T_linea = 1
       End If
    End If
    If T_linea = 1 Then
    
        'Escribimos el valor parcial del elemento
        E_fecha_flag = 0
        T_linea = 0
    End If
    
    rst.MoveNext
    rst_next.MoveNext
    
Wend

rst.Close
rst_next.Close
Set rst = Nothing
Set rst_next = Nothing
Un saludo y muchas gracias