zelarra821
Registered User.
- Local time
- Today, 22:11
- Joined
- Jan 14, 2019
- Messages
- 835
Hello.
I have the following code to lookup a value in the table. What I do is look up the maximum date in a custom function (UltimaVezPresionArterial), which I then use as criteria to look up the last value in another custom function (UltimaPresionArterialTomada). It does not give me the expected value (I get the text box empty), and I think it has to do with the format of the dates, but I am not able to fix it.
Can someone help me to solve it?
Thanks and Merry Christmas.
I have the following code to lookup a value in the table. What I do is look up the maximum date in a custom function (UltimaVezPresionArterial), which I then use as criteria to look up the last value in another custom function (UltimaPresionArterialTomada). It does not give me the expected value (I get the text box empty), and I think it has to do with the format of the dates, but I am not able to fix it.
Code:
Function UltimaPresionArterialTomada() As Variant
On Error GoTo err_lbl
UltimaPresionArterialTomada = Format(DLookup("Sistolica", "T09PresionArterial", "Fecha=#" & UltimaVezPresionArterial & "#"), "0 mm Hg") _
& " / " & Format(DLookup("Diastolica", "T09PresionArterial", "Fecha=#" & UltimaVezPresionArterial & "#"), "0 mm Hg")
Salida:
Exit Function
err_lbl:
MsgBox "UltimaPresionArterialTomada: " & Err.Number & " " & Err.Description, vbInformation, NombreBD
Resume Salida
End Function
Function UltimaVezPresionArterial() As Date
On Error GoTo err_lbl
UltimaVezPresionArterial = DMax("Fecha", "T09PresionArterial")
MsgBox UltimaVezPresionArterial
Salida:
Exit Function
err_lbl:
MsgBox "UltimaVezPresionArterial: " & Err.Number & " " & Err.Description, vbInformation, NombreBD
Resume Salida
End Function
Can someone help me to solve it?
Thanks and Merry Christmas.