I a newbie to MS Access and VBA Code, but I have been handling well my needs. The code posted bellow is the only way I got my Click Event working. In order to printout current record from multiple tables (mail merge) it's required that some fields are filled. So before the actual printout code I inserted the following code. Is there a better way to do it? It just doesn't feel right the way I did it.
If IsNull(Screen.ActiveForm![Nome]) Then
MsgBox "Preencher o Nome do Cliente."
Screen.ActiveForm![Nome].SetFocus
Else
If IsNull(Screen.ActiveForm![Gênero]) Then
MsgBox "Preencher o Gênero do Cliente."
Screen.ActiveForm![Gênero].SetFocus
Else
If IsNull(Screen.ActiveForm![Estado Civíl]) Then
MsgBox "Preencher o Estado Civíl do Cliente."
Screen.ActiveForm![cboecivil].SetFocus
Else
If IsNull(Screen.ActiveForm![Profissão]) Then
MsgBox "Preencher a Profissão do Cliente."
Screen.ActiveForm![Profissão].SetFocus
Else
If IsNull(Screen.ActiveForm![CEP]) Then
MsgBox "Preencher o CEP do Cliente."
Screen.ActiveForm![CEP].SetFocus
Else
If IsNull(Screen.ActiveForm![Endereço]) Then
MsgBox "Preencher o nome da Rua do Cliente."
Screen.ActiveForm![Endereço].SetFocus
Else
If IsNull(Screen.ActiveForm![Número]) Then
MsgBox "Preencher o Número da Rua do Cliente."
Screen.ActiveForm![Número].SetFocus
Else
If IsNull(Screen.ActiveForm![Cidade]) Then
MsgBox "Preencher a Cidade do Cliente."
Screen.ActiveForm![Cidade].SetFocus
Else
If IsNull(Screen.ActiveForm![UF]) Then
MsgBox "Preencher o Estado do Cliente."
Screen.ActiveForm![UF].SetFocus
Else
If IsNull(Screen.ActiveForm![Bairro]) Then
MsgBox "Preencher o Bairro do Cliente."
Screen.ActiveForm![Bairro].SetFocus
Else
If IsNull(Screen.ActiveForm![Complemento]) Then
MsgBox "Preencher o Complemento do Endereço do Cliente."
Screen.ActiveForm![Complemento].SetFocus
Else
If IsNull(Forms("Painel de Controle").sftblCPF.Form.CPF) Then
MsgBox "Preencher o CPF do Cliente."
Forms("Painel de Controle").sftblCPF.Form.CPF.SetFocus
Else
If IsNull(Forms("Painel de Controle").sftblRG.Form.Número) Then
MsgBox "Preencher o Número do RG do Cliente."
Forms("Painel de Controle").sftblRG.Form.Número.SetFocus
Else
If IsNull(Forms("Painel de Controle").sftblRG.Form.Série) Then
MsgBox "Preencher a Série do RG do Cliente."
Forms("Painel de Controle").sftblRG.Form.Série.SetFocus
Else
If IsNull(Forms("Painel de Controle").sftblRG.Form.[Orgão Emissor]) Then
MsgBox "Preencher o Orgão Emissor do RG do Cliente."
Forms("Painel de Controle").sftblRG.Form.[Orgão Emissor].SetFocus
Else
If Forms("Painel de Controle").sftblCPF.Form.[Principal?] = False Then
MsgBox "Marcar o CPF Principal do Cliente."
Forms("Painel de Controle").sftblCPF.Form.[Principal?].SetFocus
Else
If Forms("Painel de Controle").sftblRG.Form.[Principal?] = False Then
MsgBox "Marcar o RG Principal do Cliente."
Forms("Painel de Controle").sftblRG.Form.[Principal?].SetFocus
Else
'MailMerge code inserted Here.
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If