INPUT BOX NA EXECU?ÃO SQL
pessoal tenho esse trecho de programa...mas tem um momento q aprece uma input box escrito tblsumhour enter parameter values...mas funciona dando ok na input...mas da onde vem esse erro q nao acho
Sub Organize()
Dim rsSum, rsTotal As DAO.Recordset
Dim Validation As Boolean
Set rsSum = CurrentDb.OpenRecordset("tblSumHour")
Set rsTotal = CurrentDb.OpenRecordset("tblResume")
DoCmd.SetWarnings False
DoCmd.RunSQL "DELETE FROM tblResume"
'--------
'CHECK OF EFFECTIVITY
'--------
If (rsSum.BOF = True And rsSum.EOF = True) Then
MsgBox "Sum Hour is Empty. No data to organize", vbInformation, "Report"
Exit Sub
End If
rsSum.MoveFirst
'PRENCHE A TABELA RESUME COM A SOMA DAS HORAS, SEPARANDO POR TASKS
Do Until rsSum.EOF = True
If (rsTotal.EOF = True And rsTotal.BOF = True) Then
With rsTotal
.AddNew
.Fields("site") = rsSum.Fields("site")
.Fields("company") = rsSum.Fields("company")
.Fields("acft") = rsSum.Fields("acft")
Select Case rsSum.Fields("task")
Case "AIPC"
.Fields("aipc") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
Case "AMM"
.Fields("amm") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
Case "CMM"
.Fields("cmm") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
Case "Product Support"
.Fields("product") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
Case "SB"
.Fields("sb") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
Case "Reliability"
.Fields("reliability") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
End Select
.Fields("data") = rsSum.Fields("data")
.Update
rsTotal.MoveFirst
End With
Else
rsTotal.MoveFirst
End If
Validation = False
Do Until rsTotal.EOF = True
If (rsTotal.Fields("site") = rsSum.Fields("site")) Then
If (rsTotal.Fields("acft") = rsSum.Fields("acft")) Then
If (rsTotal.Fields("company") = rsSum.Fields("company")) Then
Validation = True
Exit Do
End If
End If
End If
rsTotal.MoveNext
Loop
If Validation = True Then
'BLOCO SERA EXECUTADO SE JA EXISTIR UMA ATIVIDADE PREENCHENDO SOMENTE A TASK
With rsTotal
.Edit
Select Case rsSum.Fields("task")
Case "AIPC"
.Fields("aipc") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
Case "AMM"
.Fields("amm") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
Case "CMM"
.Fields("cmm") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
Case "Product Support"
.Fields("product") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
Case "SB"
.Fields("sb") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
Case "Reliability"
.Fields("reliability") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
End Select
.Update
End With
Else
'CASO NAO TENHA A ATIVIDADE
With rsTotal
.AddNew
.Fields("site") = rsSum.Fields("site")
.Fields("company") = rsSum.Fields("company")
.Fields("acft") = rsSum.Fields("acft")
Select Case rsSum.Fields("task")
Case "AIPC"
.Fields("aipc") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
Case "AMM"
.Fields("amm") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
Case "CMM"
.Fields("cmm") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
Case "Product Support"
.Fields("product") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
Case "SB"
.Fields("sb") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
Case "Reliability"
.Fields("reliability") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
End Select
.Fields("data") = rsSum.Fields("data")
.Update
End With
End If
rsSum.MoveNext
DoEvents
Loop
DoCmd.RunSQL "UPDATE tblResume SET sumhour = aipc + amm + cmm + product + sb + reliability WHERE sumhour = 0"
End Sub
Sub Organize()
Dim rsSum, rsTotal As DAO.Recordset
Dim Validation As Boolean
Set rsSum = CurrentDb.OpenRecordset("tblSumHour")
Set rsTotal = CurrentDb.OpenRecordset("tblResume")
DoCmd.SetWarnings False
DoCmd.RunSQL "DELETE FROM tblResume"
'--------
'CHECK OF EFFECTIVITY
'--------
If (rsSum.BOF = True And rsSum.EOF = True) Then
MsgBox "Sum Hour is Empty. No data to organize", vbInformation, "Report"
Exit Sub
End If
rsSum.MoveFirst
'PRENCHE A TABELA RESUME COM A SOMA DAS HORAS, SEPARANDO POR TASKS
Do Until rsSum.EOF = True
If (rsTotal.EOF = True And rsTotal.BOF = True) Then
With rsTotal
.AddNew
.Fields("site") = rsSum.Fields("site")
.Fields("company") = rsSum.Fields("company")
.Fields("acft") = rsSum.Fields("acft")
Select Case rsSum.Fields("task")
Case "AIPC"
.Fields("aipc") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
Case "AMM"
.Fields("amm") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
Case "CMM"
.Fields("cmm") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
Case "Product Support"
.Fields("product") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
Case "SB"
.Fields("sb") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
Case "Reliability"
.Fields("reliability") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
End Select
.Fields("data") = rsSum.Fields("data")
.Update
rsTotal.MoveFirst
End With
Else
rsTotal.MoveFirst
End If
Validation = False
Do Until rsTotal.EOF = True
If (rsTotal.Fields("site") = rsSum.Fields("site")) Then
If (rsTotal.Fields("acft") = rsSum.Fields("acft")) Then
If (rsTotal.Fields("company") = rsSum.Fields("company")) Then
Validation = True
Exit Do
End If
End If
End If
rsTotal.MoveNext
Loop
If Validation = True Then
'BLOCO SERA EXECUTADO SE JA EXISTIR UMA ATIVIDADE PREENCHENDO SOMENTE A TASK
With rsTotal
.Edit
Select Case rsSum.Fields("task")
Case "AIPC"
.Fields("aipc") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
Case "AMM"
.Fields("amm") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
Case "CMM"
.Fields("cmm") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
Case "Product Support"
.Fields("product") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
Case "SB"
.Fields("sb") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
Case "Reliability"
.Fields("reliability") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
End Select
.Update
End With
Else
'CASO NAO TENHA A ATIVIDADE
With rsTotal
.AddNew
.Fields("site") = rsSum.Fields("site")
.Fields("company") = rsSum.Fields("company")
.Fields("acft") = rsSum.Fields("acft")
Select Case rsSum.Fields("task")
Case "AIPC"
.Fields("aipc") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
Case "AMM"
.Fields("amm") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
Case "CMM"
.Fields("cmm") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
Case "Product Support"
.Fields("product") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
Case "SB"
.Fields("sb") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
Case "Reliability"
.Fields("reliability") = rsSum.Fields("hours") + rsSum.Fields("h50") + rsSum.Fields("h100")
End Select
.Fields("data") = rsSum.Fields("data")
.Update
End With
End If
rsSum.MoveNext
DoEvents
Loop
DoCmd.RunSQL "UPDATE tblResume SET sumhour = aipc + amm + cmm + product + sb + reliability WHERE sumhour = 0"
End Sub
ops...achei...foi mal era no report....
Tópico encerrado , respostas não são mais permitidas