OK, I am newbie to Access. I did however managed to create several simple DBs, but I am now stuck with this problem. I am making a rather complex database that needs to have a sort of calculator within.
There is a medical formula for a something called MELD score. The original formula is:
MELD Score = 0.957 x Ln(creatinine mg/dL)
+ 0.378 x Ln(bilirubin mg/dL)
+ 1.120 x Ln(INR)
+ 0.643
I know that VBA function Log actually is Ln math function. So here is how I set up the scene. I created a simple table that has creatinine, bilirubin, INR and of course MELD field. I also created a query for a table and a form linked to that query. The form is designed in that way that when you click on MELD field you automatically get a calculated MELD value. Here is the code:
Private Sub MELD_Click()
Dim LnCrea
LnCrea = Log([Kreatinin] / 88.4)
Dim LnTbil
LnTbil = Log([Bilirubin] / 17.1)
Dim LnINR
LnINR = Log([INR])
[MELD] = (9.57 * LnCrea) + (3.78 * LnTbil) + (11.2 * LnINR) + 6.43
End Sub
Note that entered values of creatinin are in different units, so a conversion must be performed (Creatinin/88.4 etc) before entering into formula. Now, everything works as it should, except I am getting wrong result at the end (since I have the same calculator in Excel which is confirmed to work OK).
What am I doing wrong? I've lost entire weekend starring into this code and trying different thing - but without success. TNX in advance
Nermin
There is a medical formula for a something called MELD score. The original formula is:
MELD Score = 0.957 x Ln(creatinine mg/dL)
+ 0.378 x Ln(bilirubin mg/dL)
+ 1.120 x Ln(INR)
+ 0.643
I know that VBA function Log actually is Ln math function. So here is how I set up the scene. I created a simple table that has creatinine, bilirubin, INR and of course MELD field. I also created a query for a table and a form linked to that query. The form is designed in that way that when you click on MELD field you automatically get a calculated MELD value. Here is the code:
Private Sub MELD_Click()
Dim LnCrea
LnCrea = Log([Kreatinin] / 88.4)
Dim LnTbil
LnTbil = Log([Bilirubin] / 17.1)
Dim LnINR
LnINR = Log([INR])
[MELD] = (9.57 * LnCrea) + (3.78 * LnTbil) + (11.2 * LnINR) + 6.43
End Sub
Note that entered values of creatinin are in different units, so a conversion must be performed (Creatinin/88.4 etc) before entering into formula. Now, everything works as it should, except I am getting wrong result at the end (since I have the same calculator in Excel which is confirmed to work OK).
What am I doing wrong? I've lost entire weekend starring into this code and trying different thing - but without success. TNX in advance
Nermin