Ya, está muchas gracias, solo me falta un detalle, bueno eso creo ya que cnforme avanzo voy viendo que todavia algo mas tengo que hacerle.
En esta imagen puedes ver hay un text que esta de color purpura, ese campo lo he denominado txtMarT y quisiera que tomara el valor sumando los campos que estan en azul.
mi codigo es el siguiente:
Código HTML:
Dim Cn As ADODB.Connection
Dim Rs As ADODB.Recordset
Private Sub Form_Load()
Dim fechaini As Date
Dim num1 As Integer
Dim num2 As Integer
Dim num3 As Integer
Dim num4 As Integer
Dim num5 As Integer
Dim num6 As Integer
Dim num7 As Integer
Dim num8 As Integer
Dim num9 As Integer
Dim num10 As Integer
Dim num11 As Integer
Dim num12 As Integer
Dim num13 As Integer
Dim num14 As Integer
Dim num15 As Integer
Dim num16 As Integer
Dim num17 As Integer
Dim num18 As Integer
Dim num19 As Integer
Dim num20 As Integer
Dim num21 As Integer
Dim num22 As Integer
Dim num23 As Integer
Dim num24 As Integer
Dim num25 As Integer
Dim num26 As Integer
Set Cn = New ADODB.Connection
Set Rs = New ADODB.Recordset
Cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\ims\informesemanal.MDB;" & _
"Persist Security Info=False"
Rs.ActiveConnection = Cn
Rs.CursorType = adOpenKeyset
Rs.LockType = adLockOptimistic
'InicioSemana = FormatDateTime(Date - Weekday(Date) - 1, vbGeneralDate)
'FinSemana = FormatDateTime(Date - Weekday(Date) + 5, vbGeneralDate)
'fechaini = Format(InicioSemana, "MM-DD-YYYY")
'fechafin = Format(FinSemana, "MM-DD-YY")
fechaini = "13/05/2011"
fechafin = "19/05/2011"
Rs.Open "Select * From reportesemanal Where fecha BETWEEN #" & fechaini & "# AND #" & fechafin & "#"
If Not Rs.EOF And Not Rs.BOF Then
While Not Rs.EOF
If Rs.Fields("dia") = "viernes" Then
num1 = Rs.Fields("AltoRiesgo")
num2 = Rs.Fields("AltoRiesgoV")
num3 = Rs.Fields("BajoRiesgo")
num4 = Rs.Fields("BajoRiesgoV")
totalAltoriesgo = Rs.Fields("AltoRiesgo") + Rs.Fields("AltoRiesgoV")
TxtMArV = Rs.Fields("AltoRiesgo")
TxtMBrV = Rs.Fields("BajoRiesgo")
TxtVArV = Rs.Fields("AltoRiesgoV")
TxtVBrV = Rs.Fields("BajoRiesgoV")
TxtTArV = num1 + num2
TxtTBrV = num3 + num4
End If
If Rs.Fields("dia") = "lunes" Then
num5 = Rs.Fields("AltoRiesgo")
num6 = Rs.Fields("AltoRiesgoV")
num7 = Rs.Fields("BajoRiesgo")
num8 = Rs.Fields("BajoRiesgoV")
TxtMArL = Rs.Fields("AltoRiesgo")
TxtMBrL = Rs.Fields("BajoRiesgo")
TxtVArL = Rs.Fields("AltoRiesgoV")
TxtVBrL = Rs.Fields("BajoRiesgoV")
TxtTArL = num5 + num6
TxtTBrL = num7 + num8
End If
If Rs.Fields("dia") = "martes" Then
num9 = Rs.Fields("AltoRiesgo")
num10 = Rs.Fields("AltoRiesgoV")
num11 = Rs.Fields("BajoRiesgo")
num12 = Rs.Fields("BajoRiesgoV")
TxtTArM = num9 + num10
TxtTBrM = num11 + num12
TxtMArM = Rs.Fields("AltoRiesgo")
TxtMBrM = Rs.Fields("BajoRiesgo")
TxtVArM = Rs.Fields("AltoRiesgoV")
TxtVBrM = Rs.Fields("BajoRiesgoV")
End If
If Rs.Fields("dia") = "miércoles" Then
num13 = Rs.Fields("AltoRiesgo")
num14 = Rs.Fields("AltoRiesgoV")
num15 = Rs.Fields("BajoRiesgo")
num16 = Rs.Fields("BajoRiesgoV")
TxtTArMi = num13 + num14
TxtTBrMi = num15 + num16
TxtMArMi = Rs.Fields("AltoRiesgo")
TxtMBrMi = Rs.Fields("BajoRiesgo")
TxtVArMi = Rs.Fields("AltoRiesgoV")
TxtVBrMi = Rs.Fields("BajoRiesgoV")
End If
If Rs.Fields("dia") = "jueves" Then
num17 = Rs.Fields("AltoRiesgo")
num18 = Rs.Fields("AltoRiesgoV")
num19 = Rs.Fields("BajoRiesgo")
num20 = Rs.Fields("BajoRiesgoV")
TxtTArJ = num17 + num18
TxtTBrJ = num19 + num20
TxtMArJ = Rs.Fields("AltoRiesgo")
TxtMBrJ = Rs.Fields("BajoRiesgo")
TxtVArJ = Rs.Fields("AltoRiesgoV")
TxtVBrJ = Rs.Fields("BajoRiesgoV")
End If
Rs.MoveNext
Wend
End If
Rs.Close
End Sub
Private Sub Form_Unload(Cancel As Integer)
Cn.Close
Set Cn = Nothing
End Sub
En donde espero poder ponerle al campo TxtMarT la variable num21 que seria la suma de num1 + num5 + num9 + num13 + num17.
mi problema es que yo tengo esas variables en diferentes if y no puedo tomarlas.
Saludos les agradezco mucho su ayuda.