Boa tarde
As duvidas vão explicadas no Form de abertura
Obrigado
As duvidas vão explicadas no Form de abertura
Obrigado
Private Sub localizartexto_Change()
Dim Rst As DAO.Recordset
Dim RstMasc As DAO.Recordset
Dim RstFem As DAO.Recordset
Dim C As String, X As String
X = Me.localizartexto.Text
C = " where nome like '*" & X & "*' or dteBirthdate like '*" & X & "*' or localidade like '*" & X & "*'or Endereço like '*" & X & "*'or cidade like '*" & X & "*' or [UTENTE] like '*" & X & "*'"
Me.VerPacientes.Form.RecordSource = "select * from [Pacientes Consulta]" & C
Set Rst = Me.VerPacientes.Form.RecordsetClone
Rst.Filter = "Sexo='Masculino'"
Set RstMasc = Rst.OpenRecordset
If RstMasc.RecordCount > 0 Then RstMasc.MoveLast: RstMasc.MoveFirst
Me.VerPacientes.Form!Masculino = RstMasc.RecordCount
Rst.Filter = "Sexo='Feminino'"
Set RstFem = Rst.OpenRecordset
If RstFem.RecordCount > 0 Then RstFem.MoveLast: RstFem.MoveFirst
Me.VerPacientes.Form!Feminino = RstFem.RecordCount
If Rst.RecordCount = 0 Then
Me.VerPacientes.Form!PercentMasc = "0 %"
Me.VerPacientes.Form!PercentFem = "0 %"
Else
Me.VerPacientes.Form!PercentMasc = Format(RstMasc.RecordCount / Rst.RecordCount, "0.## %")
Me.VerPacientes.Form!PercentFem = Format(RstFem.RecordCount / Rst.RecordCount, "0.## %")
End If
Set Rst = Nothing
Set RstMasc = Nothing
Set RstFem = Nothing
End Sub