Bom dia.
Tenho um relatório que deveria trabalhar assim:
Até dia 16/06/2015 usaria um campo do BD
Após, outro campo, conforme código abaixo:
Option Compare Database
Option Explicit
Private strTipoFeriado As String
Private intDiaFeriado, IntMesFeriado As Integer
Private intNum, intCont As Integer
Private rsFunc, rsFaltas, rsFeriados, rsRecesso As DAO.Recordset
Private Sub Report_Load()
Dim strMes As String
Dim intAno, intReg, intDia, intDataFim As Integer
Dim strEntrada, strIniAlm, strFimAlm, strSaida, strEHTP, strSHTP, strFalta, strCargo, strPeriodo, strRecesso As String
Dim db As DAO.Database
Dim dtData As Date
intAno = Form_Cartao_Ponto.txtAno
strMes = Form_Cartao_Ponto.cmbMes
intReg = Nz(Form_Cartao_Ponto.txtREG, 0)
Set db = CurrentDb
Select Case Form_Cartao_Ponto.qdoQuantidade
Case 1
Set rsFunc = db.OpenRecordset("Select * From tb_Func where [REG_FUNC] = " & intReg & "")
Set rsFaltas = db.OpenRecordset("Select [DIA_FALTA], [DATA_FALTA], [MOTIVO_FALTA] From tb_Faltas Where [REG]=" & intReg & " And [MES_FALTA]='" & strMes & "' And [ANO]=" & intAno & "")
Case 2
Set rsFunc = db.OpenRecordset("Select * From tb_Func where [CARGO] in ('Secretário de Escola', 'Professroa Responsável', 'PPI', 'PEB I', 'Inspetor de Alunos') And [2014] = 'SIM' Order by [NOME_FUNC]")
intReg = rsFunc("REG_FUNC")
Set rsFaltas = db.OpenRecordset("Select [DIA_FALTA], [DATA_FALTA], [MOTIVO_FALTA] From tb_Faltas Where [REG]=" & intReg & " And [MES_FALTA]='" & strMes & "' And [ANO]=" & intAno & "")
End Select
Me.txtREG.Value = rsFunc("REG_FUNC")
Me.txtNome.Value = rsFunc("NOME_FUNC")
Me.txtCARGO.Value = rsFunc("CARGO")
Me.txtMes.Value = strMes
Me.txtAno.Value = intAno
strEntrada = rsFunc("ENTRADA")
strIniAlm = rsFunc("ENTRADA_ALMOCO")
strFimAlm = rsFunc("SAIDA_ALMOCO")
strSaida = rsFunc("SAIDA")
strEHTP = rsFunc("ENTRADA_HTP")
strSHTP = rsFunc("SAIDA_HTP")
strCargo = rsFunc("CARGO")
strPeriodo = rsFunc("PERIODO")
If IsNull(strPeriodo) Or IsNull(strCargo) Then
MsgBox ("Período de trabalho ou Cargo não selecionados!"), vbInformation + vbOKOnly, "Dados Insuficientes"
Exit Sub
End If
Select Case strMes
Case "Janeiro"
intNum = "01"
intDataFim = "31"
Case "Fevereiro"
If intAno Mod 400 = 0 Or (intAno Mod 4 = 0 And intAno Mod 100 <> 0) Then
intNum = "02"
intDataFim = "29"
Else
intNum = "02"
intDataFim = "28"
End If
Case "Março"
intNum = "03"
intDataFim = "31"
Case "Abril"
intNum = "04"
intDataFim = "30"
Case "Maio"
intNum = "05"
intDataFim = "31"
Case "Junho"
intNum = "06"
intDataFim = "30"
Case "Julho"
intNum = "07"
intDataFim = "31"
Case "Agosto"
intNum = "08"
intDataFim = "31"
Case "Setembro"
intNum = "09"
intDataFim = "30"
Case "Outubro"
intNum = "10"
intDataFim = "31"
Case "Novembro"
intNum = "11"
intDataFim = "30"
Case "Dezembro"
intNum = "12"
intDataFim = "31"
End Select
For intCont = 1 To intDataFim
intDia = Weekday(intCont & "/" & intNum & "/" & intAno)
If intDia <= #6/16/2015# Then
strEntrada = rsFunc("Entrada_Compensada")
strSaida = rsFunc("Saida_Compensada")
Else
strEntrada = rsFunc("ENTRADA")
strSaida = rsFunc("SAIDA")
End If
Set rsFeriados = db.OpenRecordset("Select [Dia_Feriado], [Tipo_Feriado] from tb_Feriados where [Dia_Feriado] = " & intCont & _
" And [Mes_Feriado] = " & intNum & "")
If rsFeriados.RecordCount <> 0 Then strTipoFeriado = rsFeriados("Tipo_Feriado")
Set rsRecesso = db.OpenRecordset("Select [Dia_Recesso] from tb_Recesso where [Dia_Recesso] = " & intCont & _
" And [Mes_Recesso] = " & intNum & "")
If rsRecesso.RecordCount <> 0 Then strRecesso = "RECESSO ESCOLAR"
Select Case strCargo
'Cartão dos Inspetores de Alunos
Case "Inspetor de Alunos"
If rsFaltas.RecordCount <> 0 Then rsFaltas.MoveFirst
rsFaltas.FindFirst "DIA_FALTA=" & intCont
If rsFaltas.NoMatch Then
intDia = Weekday(intCont & "/" & intNum & "/" & intAno)
Me("lblF" & intCont).Visible = False
Me("lblHM" & intCont).Visible = False
Me("lblHT" & intCont).Visible = False
Select Case intDia
Case 1
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = "DOMINGO"
Case 2, 3, 4, 5, 6
Me("txtME" & intCont).Value = strEntrada
Me("txtMS" & intCont).Value = strIniAlm
Me("txtTE" & intCont).Value = strFimAlm
Me("txtTS" & intCont).Value = strSaida
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Case 7
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = "SÁBADO"
End Select
Else
Me("lblF" & intCont).Caption = rsFaltas("MOTIVO_FALTA")
Me("lblF" & intCont).Visible = True
End If
'Cartão do Secretário de Escola
Case "Secretário de Escola"
If rsFaltas.RecordCount <> 0 Then rsFaltas.MoveFirst
rsFaltas.FindFirst "DIA_FALTA=" & intCont
If rsFaltas.NoMatch Then
intDia = Weekday(intCont & "/" & intNum & "/" & intAno)
Me("lblF" & intCont).Visible = False
Me("lblHM" & intCont).Visible = False
Me("lblHT" & intCont).Visible = False
Select Case intDia
Case 1
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = "DOMINGO"
Case 3, 5
Me("txtME" & intCont).Value = strEntrada
Me("txtMS" & intCont).Value = strIniAlm
Me("txtTE" & intCont).Value = strFimAlm
Me("txtTS" & intCont).Value = strSaida
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Case 2, 4, 6
Me("txtME" & intCont).Value = "07:00"
Me("txtMS" & intCont).Value = "12:00"
Me("txtTE" & intCont).Value = "13:00"
Me("txtTS" & intCont).Value = "16:20"
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Case 7
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = "SÁBADO"
End Select
Else
Me("lblF" & intCont).Caption = rsFaltas("MOTIVO_FALTA")
Me("lblF" & intCont).Visible = True
End If
'Cartão da Professora Responsável
Case "Professora Responsável"
If rsFaltas.RecordCount <> 0 Then rsFaltas.MoveFirst
rsFaltas.FindFirst "DIA_FALTA=" & intCont
If rsFaltas.NoMatch Then
intDia = Weekday(intCont & "/" & intNum & "/" & intAno)
Me("lblF" & intCont).Visible = False
Me("lblHM" & intCont).Visible = False
Me("lblHT" & intCont).Visible = False
Select Case intDia
Case 1
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = "DOMINGO"
Case 3, 5
Me("txtME" & intCont).Value = strEntrada
Me("txtMS" & intCont).Value = strIniAlm
Me("txtTE" & intCont).Value = strFimAlm
Me("txtTS" & intCont).Value = strSaida
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Case 2, 4, 6
Me("txtME" & intCont).Value = "08:10"
Me("txtMS" & intCont).Value = "12:30"
Me("txtTE" & intCont).Value = "13:30"
Me("txtTS" & intCont).Value = "17:30"
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Case 7
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = "SÁBADO"
End Select
Else
Me("lblF" & intCont).Caption = rsFaltas("MOTIVO_FALTA")
Me("lblF" & intCont).Visible = True
End If
'Cartão das Professoras de Primeira Infáncia (PPI)
Case "PPI"
Select Case strPeriodo
'Professoras do período da Manhã
Case "Manhã"
If rsFaltas.RecordCount <> 0 Then rsFaltas.MoveFirst
rsFaltas.FindFirst "DIA_FALTA=" & intCont
If rsFaltas.NoMatch Then
intDia = Weekday(intCont & "/" & intNum & "/" & intAno)
Me("lblF" & intCont).Visible = False
Me("lblHM" & intCont).Visible = False
Me("lblHT" & intCont).Visible = False
Select Case intDia
Case 1
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = "DOMINGO"
Case 2, 3, 4, 5, 6
Me("txtME" & intCont).Value = strEntrada
Me("txtMS" & intCont).Value = strIniAlm
Me("txtTE" & intCont).Value = strFimAlm
Me("txtTS" & intCont).Value = strSaida
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Case 7
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = "SÁBADO"
End Select
Else
If rsFaltas("MOTIVO_FALTA") = "FALTA HTP" Or rsFaltas("MOTIVO_FALTA") = "ATESTADO HTP" Then
Me("txtME" & intCont).Value = strEntrada
Me("txtMS" & intCont).Value = strIniAlm
Me("txtTE" & intCont).Value = strFimAlm
Me("txtTS" & intCont).Value = strSaida
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblHM" & intCont).Caption = rsFaltas("MOTIVO_FALTA")
Me("lblHM" & intCont).Visible = True
Else
Me("lblF" & intCont).Caption = rsFaltas("MOTIVO_FALTA")
Me("lblF" & intCont).Visible = True
End If
End If
'Professoras do período da Tarde
Case "Tarde"
If rsFaltas.RecordCount <> 0 Then rsFaltas.MoveFirst
rsFaltas.FindFirst "DIA_FALTA=" & intCont
If rsFaltas.NoMatch Then
intDia = Weekday(intCont & "/" & intNum & "/" & intAno)
Me("lblF" & intCont).Visible = False
Me("lblHM" & intCont).Visible = False
Me("lblHT" & intCont).Visible = False
Select Case intDia
Case 1
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = "DOMINGO"
Case 2, 3, 4, 5, 6
Me("txtME" & intCont).Value = strEntrada
Me("txtMS" & intCont).Value = strIniAlm
Me("txtTE" & intCont).Value = strFimAlm
Me("txtTS" & intCont).Value = strSaida
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Case 7
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = "SÁBADO"
End Select
Else
If rsFaltas("MOTIVO_FALTA") = "FALTA HTP" Or rsFaltas("MOTIVO_FALTA") = "ATESTADO HTP" Then
Me("txtME" & intCont).Value = strEntrada
Me("txtMS" & intCont).Value = strIniAlm
Me("txtTE" & intCont).Value = strFimAlm
Me("txtTS" & intCont).Value = strSaida
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblHM" & intCont).Caption = rsFaltas("MOTIVO_FALTA")
Me("lblHM" & intCont).Visible = True
Else
Me("lblF" & intCont).Caption = rsFaltas("MOTIVO_FALTA")
Me("lblF" & intCont).Visible = True
End If
End If
End Select
'Cartão das Professoras de Edicação Básica (PEBI)
Case "PEB I"
Select Case strPeriodo
'Professoras do período da Manhã
Case "Manhã"
If rsFaltas.RecordCount <> 0 Then rsFaltas.MoveFirst
rsFaltas.FindFirst "DIA_FALTA=" & intCont
If rsFaltas.NoMatch Then
intDia = Weekday(intCont & "/" & intNum & "/" & intAno)
Me("lblF" & intCont).Visible = False
Me("lblHM" & intCont).Visible = False
Me("lblHT" & intCont).Visible = False
Select Case intDia
Case 1
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = "DOMINGO"
Case 2, 4, 6
Me("txtME" & intCont).Value = strEntrada
Me("txtMS" & intCont).Value = strSaida
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Case 3, 5
Me("txtME" & intCont).Value = strEntrada
Me("txtMS" & intCont).Value = strSHTP
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Case 7
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = "SÁBADO"
End Select
Else
If rsFaltas("MOTIVO_FALTA") = "FALTA HTP" Or rsFaltas("MOTIVO_FALTA") = "ATESTADO HTP" Then
Me("txtME" & intCont).Value = strEntrada
Me("txtMS" & intCont).Value = strSaida
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblHT" & intCont).Caption = rsFaltas("MOTIVO_FALTA")
Me("lblHT" & intCont).Visible = True
Else
Me("lblF" & intCont).Caption = rsFaltas("MOTIVO_FALTA")
Me("lblF" & intCont).Visible = True
End If
End If
'Professoras do período da Tarde
Case "Tarde"
If rsFaltas.RecordCount <> 0 Then rsFaltas.MoveFirst
rsFaltas.FindFirst "DIA_FALTA=" & intCont
If rsFaltas.NoMatch Then
intDia = Weekday(intCont & "/" & intNum & "/" & intAno)
Me("lblF" & intCont).Visible = False
Me("lblHM" & intCont).Visible = False
Me("lblHT" & intCont).Visible = False
Select Case intDia
Case 1
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = "DOMINGO"
Case 2, 4, 6
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = strEntrada
Me("txtTS" & intCont).Value = strSaida
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Case 3, 5
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = strEHTP
Me("txtTS" & intCont).Value = strSaida
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Case 7
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = "SÁBADO"
End Select
Else
If rsFaltas("MOTIVO_FALTA") = "FALTA HTP" Or rsFaltas("MOTIVO_FALTA") = "ATESTADO HTP" Then
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = strEntrada
Me("txtTS" & intCont).Value = strSaida
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblHM" & intCont).Caption = rsFaltas("MOTIVO_FALTA")
Me("lblHM" & intCont).Visible = True
Else
Me("lblF" & intCont).Caption = rsFaltas("MOTIVO_FALTA")
Me("lblF" & intCont).Visible = True
End If
End If
End Select
End Select
If rsFeriados.RecordCount <> 0 Then rsFeriados.MoveFirst
rsFeriados.FindFirst "Dia_Feriado=" & intCont
If rsFeriados.NoMatch Then
intDia = Weekday(intCont & "/" & intNum & "/" & intAno)
Else
If Weekday(rsFeriados("Dia_Feriado") & "/" & intNum & "/" & intAno) = 1 Then
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = "DOMINGO"
ElseIf Weekday(rsFeriados("Dia_Feriado") & "/" & intNum & "/" & intAno) = 7 Then
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = "SÁBADO"
Else
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = strTipoFeriado
End If
End If
If strCargo = "PPI" Or strCargo = "PEB I" Then
If rsRecesso.RecordCount <> 0 Then rsRecesso.MoveFirst
rsRecesso.FindFirst "Dia_Recesso=" & intCont
If rsRecesso.NoMatch Then
intDia = Weekday(intCont & "/" & intNum & "/" & intAno)
Else
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = strRecesso
End If
End If
Next intCont
End Sub
No meu não está funcionando. Nada acontece.
PS: A parte em destaque é a que deveria fazer a troca.
Alguma ajuda?
Grato desde já.
Tenho um relatório que deveria trabalhar assim:
Até dia 16/06/2015 usaria um campo do BD
Após, outro campo, conforme código abaixo:
Option Compare Database
Option Explicit
Private strTipoFeriado As String
Private intDiaFeriado, IntMesFeriado As Integer
Private intNum, intCont As Integer
Private rsFunc, rsFaltas, rsFeriados, rsRecesso As DAO.Recordset
Private Sub Report_Load()
Dim strMes As String
Dim intAno, intReg, intDia, intDataFim As Integer
Dim strEntrada, strIniAlm, strFimAlm, strSaida, strEHTP, strSHTP, strFalta, strCargo, strPeriodo, strRecesso As String
Dim db As DAO.Database
Dim dtData As Date
intAno = Form_Cartao_Ponto.txtAno
strMes = Form_Cartao_Ponto.cmbMes
intReg = Nz(Form_Cartao_Ponto.txtREG, 0)
Set db = CurrentDb
Select Case Form_Cartao_Ponto.qdoQuantidade
Case 1
Set rsFunc = db.OpenRecordset("Select * From tb_Func where [REG_FUNC] = " & intReg & "")
Set rsFaltas = db.OpenRecordset("Select [DIA_FALTA], [DATA_FALTA], [MOTIVO_FALTA] From tb_Faltas Where [REG]=" & intReg & " And [MES_FALTA]='" & strMes & "' And [ANO]=" & intAno & "")
Case 2
Set rsFunc = db.OpenRecordset("Select * From tb_Func where [CARGO] in ('Secretário de Escola', 'Professroa Responsável', 'PPI', 'PEB I', 'Inspetor de Alunos') And [2014] = 'SIM' Order by [NOME_FUNC]")
intReg = rsFunc("REG_FUNC")
Set rsFaltas = db.OpenRecordset("Select [DIA_FALTA], [DATA_FALTA], [MOTIVO_FALTA] From tb_Faltas Where [REG]=" & intReg & " And [MES_FALTA]='" & strMes & "' And [ANO]=" & intAno & "")
End Select
Me.txtREG.Value = rsFunc("REG_FUNC")
Me.txtNome.Value = rsFunc("NOME_FUNC")
Me.txtCARGO.Value = rsFunc("CARGO")
Me.txtMes.Value = strMes
Me.txtAno.Value = intAno
strEntrada = rsFunc("ENTRADA")
strIniAlm = rsFunc("ENTRADA_ALMOCO")
strFimAlm = rsFunc("SAIDA_ALMOCO")
strSaida = rsFunc("SAIDA")
strEHTP = rsFunc("ENTRADA_HTP")
strSHTP = rsFunc("SAIDA_HTP")
strCargo = rsFunc("CARGO")
strPeriodo = rsFunc("PERIODO")
If IsNull(strPeriodo) Or IsNull(strCargo) Then
MsgBox ("Período de trabalho ou Cargo não selecionados!"), vbInformation + vbOKOnly, "Dados Insuficientes"
Exit Sub
End If
Select Case strMes
Case "Janeiro"
intNum = "01"
intDataFim = "31"
Case "Fevereiro"
If intAno Mod 400 = 0 Or (intAno Mod 4 = 0 And intAno Mod 100 <> 0) Then
intNum = "02"
intDataFim = "29"
Else
intNum = "02"
intDataFim = "28"
End If
Case "Março"
intNum = "03"
intDataFim = "31"
Case "Abril"
intNum = "04"
intDataFim = "30"
Case "Maio"
intNum = "05"
intDataFim = "31"
Case "Junho"
intNum = "06"
intDataFim = "30"
Case "Julho"
intNum = "07"
intDataFim = "31"
Case "Agosto"
intNum = "08"
intDataFim = "31"
Case "Setembro"
intNum = "09"
intDataFim = "30"
Case "Outubro"
intNum = "10"
intDataFim = "31"
Case "Novembro"
intNum = "11"
intDataFim = "30"
Case "Dezembro"
intNum = "12"
intDataFim = "31"
End Select
For intCont = 1 To intDataFim
intDia = Weekday(intCont & "/" & intNum & "/" & intAno)
If intDia <= #6/16/2015# Then
strEntrada = rsFunc("Entrada_Compensada")
strSaida = rsFunc("Saida_Compensada")
Else
strEntrada = rsFunc("ENTRADA")
strSaida = rsFunc("SAIDA")
End If
Set rsFeriados = db.OpenRecordset("Select [Dia_Feriado], [Tipo_Feriado] from tb_Feriados where [Dia_Feriado] = " & intCont & _
" And [Mes_Feriado] = " & intNum & "")
If rsFeriados.RecordCount <> 0 Then strTipoFeriado = rsFeriados("Tipo_Feriado")
Set rsRecesso = db.OpenRecordset("Select [Dia_Recesso] from tb_Recesso where [Dia_Recesso] = " & intCont & _
" And [Mes_Recesso] = " & intNum & "")
If rsRecesso.RecordCount <> 0 Then strRecesso = "RECESSO ESCOLAR"
Select Case strCargo
'Cartão dos Inspetores de Alunos
Case "Inspetor de Alunos"
If rsFaltas.RecordCount <> 0 Then rsFaltas.MoveFirst
rsFaltas.FindFirst "DIA_FALTA=" & intCont
If rsFaltas.NoMatch Then
intDia = Weekday(intCont & "/" & intNum & "/" & intAno)
Me("lblF" & intCont).Visible = False
Me("lblHM" & intCont).Visible = False
Me("lblHT" & intCont).Visible = False
Select Case intDia
Case 1
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = "DOMINGO"
Case 2, 3, 4, 5, 6
Me("txtME" & intCont).Value = strEntrada
Me("txtMS" & intCont).Value = strIniAlm
Me("txtTE" & intCont).Value = strFimAlm
Me("txtTS" & intCont).Value = strSaida
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Case 7
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = "SÁBADO"
End Select
Else
Me("lblF" & intCont).Caption = rsFaltas("MOTIVO_FALTA")
Me("lblF" & intCont).Visible = True
End If
'Cartão do Secretário de Escola
Case "Secretário de Escola"
If rsFaltas.RecordCount <> 0 Then rsFaltas.MoveFirst
rsFaltas.FindFirst "DIA_FALTA=" & intCont
If rsFaltas.NoMatch Then
intDia = Weekday(intCont & "/" & intNum & "/" & intAno)
Me("lblF" & intCont).Visible = False
Me("lblHM" & intCont).Visible = False
Me("lblHT" & intCont).Visible = False
Select Case intDia
Case 1
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = "DOMINGO"
Case 3, 5
Me("txtME" & intCont).Value = strEntrada
Me("txtMS" & intCont).Value = strIniAlm
Me("txtTE" & intCont).Value = strFimAlm
Me("txtTS" & intCont).Value = strSaida
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Case 2, 4, 6
Me("txtME" & intCont).Value = "07:00"
Me("txtMS" & intCont).Value = "12:00"
Me("txtTE" & intCont).Value = "13:00"
Me("txtTS" & intCont).Value = "16:20"
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Case 7
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = "SÁBADO"
End Select
Else
Me("lblF" & intCont).Caption = rsFaltas("MOTIVO_FALTA")
Me("lblF" & intCont).Visible = True
End If
'Cartão da Professora Responsável
Case "Professora Responsável"
If rsFaltas.RecordCount <> 0 Then rsFaltas.MoveFirst
rsFaltas.FindFirst "DIA_FALTA=" & intCont
If rsFaltas.NoMatch Then
intDia = Weekday(intCont & "/" & intNum & "/" & intAno)
Me("lblF" & intCont).Visible = False
Me("lblHM" & intCont).Visible = False
Me("lblHT" & intCont).Visible = False
Select Case intDia
Case 1
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = "DOMINGO"
Case 3, 5
Me("txtME" & intCont).Value = strEntrada
Me("txtMS" & intCont).Value = strIniAlm
Me("txtTE" & intCont).Value = strFimAlm
Me("txtTS" & intCont).Value = strSaida
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Case 2, 4, 6
Me("txtME" & intCont).Value = "08:10"
Me("txtMS" & intCont).Value = "12:30"
Me("txtTE" & intCont).Value = "13:30"
Me("txtTS" & intCont).Value = "17:30"
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Case 7
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = "SÁBADO"
End Select
Else
Me("lblF" & intCont).Caption = rsFaltas("MOTIVO_FALTA")
Me("lblF" & intCont).Visible = True
End If
'Cartão das Professoras de Primeira Infáncia (PPI)
Case "PPI"
Select Case strPeriodo
'Professoras do período da Manhã
Case "Manhã"
If rsFaltas.RecordCount <> 0 Then rsFaltas.MoveFirst
rsFaltas.FindFirst "DIA_FALTA=" & intCont
If rsFaltas.NoMatch Then
intDia = Weekday(intCont & "/" & intNum & "/" & intAno)
Me("lblF" & intCont).Visible = False
Me("lblHM" & intCont).Visible = False
Me("lblHT" & intCont).Visible = False
Select Case intDia
Case 1
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = "DOMINGO"
Case 2, 3, 4, 5, 6
Me("txtME" & intCont).Value = strEntrada
Me("txtMS" & intCont).Value = strIniAlm
Me("txtTE" & intCont).Value = strFimAlm
Me("txtTS" & intCont).Value = strSaida
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Case 7
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = "SÁBADO"
End Select
Else
If rsFaltas("MOTIVO_FALTA") = "FALTA HTP" Or rsFaltas("MOTIVO_FALTA") = "ATESTADO HTP" Then
Me("txtME" & intCont).Value = strEntrada
Me("txtMS" & intCont).Value = strIniAlm
Me("txtTE" & intCont).Value = strFimAlm
Me("txtTS" & intCont).Value = strSaida
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblHM" & intCont).Caption = rsFaltas("MOTIVO_FALTA")
Me("lblHM" & intCont).Visible = True
Else
Me("lblF" & intCont).Caption = rsFaltas("MOTIVO_FALTA")
Me("lblF" & intCont).Visible = True
End If
End If
'Professoras do período da Tarde
Case "Tarde"
If rsFaltas.RecordCount <> 0 Then rsFaltas.MoveFirst
rsFaltas.FindFirst "DIA_FALTA=" & intCont
If rsFaltas.NoMatch Then
intDia = Weekday(intCont & "/" & intNum & "/" & intAno)
Me("lblF" & intCont).Visible = False
Me("lblHM" & intCont).Visible = False
Me("lblHT" & intCont).Visible = False
Select Case intDia
Case 1
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = "DOMINGO"
Case 2, 3, 4, 5, 6
Me("txtME" & intCont).Value = strEntrada
Me("txtMS" & intCont).Value = strIniAlm
Me("txtTE" & intCont).Value = strFimAlm
Me("txtTS" & intCont).Value = strSaida
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Case 7
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = "SÁBADO"
End Select
Else
If rsFaltas("MOTIVO_FALTA") = "FALTA HTP" Or rsFaltas("MOTIVO_FALTA") = "ATESTADO HTP" Then
Me("txtME" & intCont).Value = strEntrada
Me("txtMS" & intCont).Value = strIniAlm
Me("txtTE" & intCont).Value = strFimAlm
Me("txtTS" & intCont).Value = strSaida
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblHM" & intCont).Caption = rsFaltas("MOTIVO_FALTA")
Me("lblHM" & intCont).Visible = True
Else
Me("lblF" & intCont).Caption = rsFaltas("MOTIVO_FALTA")
Me("lblF" & intCont).Visible = True
End If
End If
End Select
'Cartão das Professoras de Edicação Básica (PEBI)
Case "PEB I"
Select Case strPeriodo
'Professoras do período da Manhã
Case "Manhã"
If rsFaltas.RecordCount <> 0 Then rsFaltas.MoveFirst
rsFaltas.FindFirst "DIA_FALTA=" & intCont
If rsFaltas.NoMatch Then
intDia = Weekday(intCont & "/" & intNum & "/" & intAno)
Me("lblF" & intCont).Visible = False
Me("lblHM" & intCont).Visible = False
Me("lblHT" & intCont).Visible = False
Select Case intDia
Case 1
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = "DOMINGO"
Case 2, 4, 6
Me("txtME" & intCont).Value = strEntrada
Me("txtMS" & intCont).Value = strSaida
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Case 3, 5
Me("txtME" & intCont).Value = strEntrada
Me("txtMS" & intCont).Value = strSHTP
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Case 7
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = "SÁBADO"
End Select
Else
If rsFaltas("MOTIVO_FALTA") = "FALTA HTP" Or rsFaltas("MOTIVO_FALTA") = "ATESTADO HTP" Then
Me("txtME" & intCont).Value = strEntrada
Me("txtMS" & intCont).Value = strSaida
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblHT" & intCont).Caption = rsFaltas("MOTIVO_FALTA")
Me("lblHT" & intCont).Visible = True
Else
Me("lblF" & intCont).Caption = rsFaltas("MOTIVO_FALTA")
Me("lblF" & intCont).Visible = True
End If
End If
'Professoras do período da Tarde
Case "Tarde"
If rsFaltas.RecordCount <> 0 Then rsFaltas.MoveFirst
rsFaltas.FindFirst "DIA_FALTA=" & intCont
If rsFaltas.NoMatch Then
intDia = Weekday(intCont & "/" & intNum & "/" & intAno)
Me("lblF" & intCont).Visible = False
Me("lblHM" & intCont).Visible = False
Me("lblHT" & intCont).Visible = False
Select Case intDia
Case 1
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = "DOMINGO"
Case 2, 4, 6
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = strEntrada
Me("txtTS" & intCont).Value = strSaida
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Case 3, 5
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = strEHTP
Me("txtTS" & intCont).Value = strSaida
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Case 7
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = "SÁBADO"
End Select
Else
If rsFaltas("MOTIVO_FALTA") = "FALTA HTP" Or rsFaltas("MOTIVO_FALTA") = "ATESTADO HTP" Then
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = strEntrada
Me("txtTS" & intCont).Value = strSaida
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblHM" & intCont).Caption = rsFaltas("MOTIVO_FALTA")
Me("lblHM" & intCont).Visible = True
Else
Me("lblF" & intCont).Caption = rsFaltas("MOTIVO_FALTA")
Me("lblF" & intCont).Visible = True
End If
End If
End Select
End Select
If rsFeriados.RecordCount <> 0 Then rsFeriados.MoveFirst
rsFeriados.FindFirst "Dia_Feriado=" & intCont
If rsFeriados.NoMatch Then
intDia = Weekday(intCont & "/" & intNum & "/" & intAno)
Else
If Weekday(rsFeriados("Dia_Feriado") & "/" & intNum & "/" & intAno) = 1 Then
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = "DOMINGO"
ElseIf Weekday(rsFeriados("Dia_Feriado") & "/" & intNum & "/" & intAno) = 7 Then
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = "SÁBADO"
Else
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = strTipoFeriado
End If
End If
If strCargo = "PPI" Or strCargo = "PEB I" Then
If rsRecesso.RecordCount <> 0 Then rsRecesso.MoveFirst
rsRecesso.FindFirst "Dia_Recesso=" & intCont
If rsRecesso.NoMatch Then
intDia = Weekday(intCont & "/" & intNum & "/" & intAno)
Else
Me("txtME" & intCont).Value = ""
Me("txtMS" & intCont).Value = ""
Me("txtTE" & intCont).Value = ""
Me("txtTS" & intCont).Value = ""
Me("txtEE" & intCont).Value = ""
Me("txtES" & intCont).Value = ""
Me("lblF" & intCont).Visible = True
Me("lblF" & intCont).Caption = strRecesso
End If
End If
Next intCont
End Sub
No meu não está funcionando. Nada acontece.
PS: A parte em destaque é a que deveria fazer a troca.
Alguma ajuda?
Grato desde já.