os seus problemas acabaram. As Organizações Tabajara têm o prazer de apresentar uma rotina de validação de garantia que funciona, na prática (é parte de um sistema que criei anos atrás, para gerenciar uma oficina de consertos eletrônicos).
Estou mandando a rotina inteira, pra vc verificar o que poderá usar. Consiste no seguinte: um label, ao ser clicado num form de consultas (que exibe um registro do banco de dados), exibe uma msgbox informando se o aparelho está na garantia ou não. Se estiver, mostra a data final da garantia. O sistema obtém esses dados do cadastro do cliente, onde existe uma data de saída do aparelho.
Private Sub Label58_Click()
On Error Resume Next
Dim MinDate As Date
Dim IntervalType, Tempo, X As String
Dim Number As Integer
Dim Resultado
IntervalType = "d"
MinDate = Label29.Caption
‘MinDate: data da saída do aparelho.
If Label31.Caption = "NÃO" And Label29.Caption > "" Then
'Se Aprovado = Não e Saída > 0 então
MsgBox "Orçamento recusado." & Chr(13) & "Retirado sem consertar.", vbInformation, " Garantia"
Exit Sub
ElseIf Label31.Caption = "SIM" And Label29.Caption = "" Then
MsgBox "Embora aprovado, não" & Chr(13) & "consta saída do aparelho.", vbInformation, " Garantia"
Exit Sub
ElseIf Label31.Caption = "NÃO" And Label29.Caption = "" Then
MsgBox "Embora não aprovado, não" & Chr(13) & "consta saída do aparelho.", vbInformation, " Garantia"
Exit Sub
ElseIf Label29.Caption = "" And Label8.Caption = "" Then
MsgBox "Orçamento não concluído." & Chr(13) & "Aparelho deixado na loja.", vbInformation, " Garantia"
Exit Sub
ElseIf Label29.Caption > "" And Label8.Caption = "" Then
MsgBox "Orçamento não concluído." & Chr(13) & "Devolvido ao cliente.", vbInformation, " Garantia"
Exit Sub
ElseIf Label29.Caption > "" And Label37.Caption = "" Then
MsgBox "Não foi estipulada garantia" & Chr(13) & "para esse aparelho ...", vbInformation, " Garantia"
Exit Sub
ElseIf Label29.Caption = "" And Label31.Caption = "" And Label37.Caption = "" Then
MsgBox "Dados cadastrais incompletos ..." & Chr(13) & "Localize os dados que faltam, clique" & Chr(13) & "em <Cadastro/Alterar> e complete" & Chr(13) & "o cadastro.", vbCritical, " Cadastro incompleto"
Exit Sub
ElseIf Label29.Caption = "31/12/2998" Then
MsgBox "Aparelho ainda não retirado.", vbInformation + vbOKOnly, "Ainda na loja."
Exit Sub
Else
Number = Label37.Caption
‘Label37 = nº de dias de garantia.
Tempo = DateAdd(IntervalType, Number, MinDate)
If Tempo < Now Then 'Se a variável Tempo (data da garantia) for < do que esta data ...
Beep
MsgBox "Garantia vencida" & Chr(13) & "em " & (Tempo) & ".", vbCritical, " Fora da garantia ..."
Exit Sub
Else
Resultado = "Garantia válida até " & (Tempo) & "."
MsgBox Resultado, vbDefaultButton4, " Período de garantia"
X = Label29.Caption
Exit Sub
End If
End If
End Sub