Finding a Median (1 Viewer)

Mobiusrune

Registered User.
Local time
Yesterday, 19:37
Joined
Jan 7, 2013
Messages
28
I have a report that calculates a average value from a field. Is there a way to figure out the median value? I did not see a function for this.
 

Mobiusrune

Registered User.
Local time
Yesterday, 19:37
Joined
Jan 7, 2013
Messages
28
Okay...(Nurse here and not IT professional)...Not to be dense, but the article states that to use this code I need to "Use the References command in the Tools menu to add the necessary reference". I did import the module just fine.

Where is the References Command and is it supposed to be in the Database Tools Ribbon? Don't mean to be a pest, but I am a little lost with this. Help?!?!?!?
 

Mobiusrune

Registered User.
Local time
Yesterday, 19:37
Joined
Jan 7, 2013
Messages
28
Do I only need to select the MS DAO Object Library? Is that what I am looking for?
 

Mihail

Registered User.
Local time
Today, 02:37
Joined
Jan 22, 2011
Messages
2,373
Try and you will know if this is ok :)
 

Mobiusrune

Registered User.
Local time
Yesterday, 19:37
Joined
Jan 7, 2013
Messages
28
I didn't get the DAO error after selecting the DAO Library. But, I am still getting the error on my report. I have the expression written as follows:

=DMedian("Expr1","qryDataAnalysisCenter")

Does this look right? The article states that the last part is optional.
 

Mihail

Registered User.
Local time
Today, 02:37
Joined
Jan 22, 2011
Messages
2,373
I never read that article :) . But now I see this function:
Public Function DMedian( _ ByVal strField As String, ByVal strDomain As String, _ Optional ByVal strCriteria As String) As Variant

And this say to me that the involved parameters for this function are:
strField - the name of that field where you have data for calculate the median
strDomain - the name of the table (or query) where the strField is

Optional you can use strCriteria in order to filter the values in that table/query.

So, your Expr1 should be the name for the field in
qryDataAnalysisCenter

=DMedian("FieldName","qryDataAnalysisCenter")
 

Mobiusrune

Registered User.
Local time
Yesterday, 19:37
Joined
Jan 7, 2013
Messages
28
Expr1 is the Field name. It is a calculated field in a qry based off of other fields from a table. Expr 1 is something like this:

IIF([Time1]>[Time2],DateDiff("n",[Time1],[Time2])+1440,DateDiff("n",[Time1],[Time2]))

Access automatically calls this field in the query Expr1. Expr1 is displayed in a report. I was able to calculate Avg([Expr1) and the StDev([Expr1]) without issue, but DMedian does not seem to like "Expr1" as a field name...

So stuck I will be for the time being.
Mihail thank you so much for your time and patience.
 

Mihail

Registered User.
Local time
Today, 02:37
Joined
Jan 22, 2011
Messages
2,373
If you upload the database me (or others) can take a look and trying to understand what happen.
 

Mobiusrune

Registered User.
Local time
Yesterday, 19:37
Joined
Jan 7, 2013
Messages
28
It won't let me. Upload only allows for 2MB and this is 5.3.
 

JHB

Have been here a while
Local time
Today, 01:37
Joined
Jun 17, 2012
Messages
7,732
Have you zipped it + a "Compact and Repair" before?
 

Mobiusrune

Registered User.
Local time
Yesterday, 19:37
Joined
Jan 7, 2013
Messages
28
No, because it is late and my brain isn't working...here it is...
 

Attachments

  • DummySepsisTracking 1.2.zip
    603.8 KB · Views: 88

Mobiusrune

Registered User.
Local time
Yesterday, 19:37
Joined
Jan 7, 2013
Messages
28
The issues is getting the Median values for the Expr# fields in the two reports. PtMRN field is blank r/t Protected Health Information.
 

Mihail

Registered User.
Local time
Today, 02:37
Joined
Jan 22, 2011
Messages
2,373
And is no need for all records if you have a huge database.
And do a Compact and Repair before uploading (or zipped).
 

Mobiusrune

Registered User.
Local time
Yesterday, 19:37
Joined
Jan 7, 2013
Messages
28
Okay...compacted and repaired...and zipped.

This is what happens when you throw a nurse into IT...but I am having fun with this...
 

Attachments

  • DummySepsisTracking 1.2.zip
    224.6 KB · Views: 80

Mihail

Registered User.
Local time
Today, 02:37
Joined
Jan 22, 2011
Messages
2,373
First error:
In Command101_Click() your stDocName point to the query not to the report.
Change the name then let us know if this solve the error.
 

Mihail

Registered User.
Local time
Today, 02:37
Joined
Jan 22, 2011
Messages
2,373
The row source for text132 in the report try to calculate the median using the report.
Change this
=DMedian("Expr1";"rptDataAnalysisCenter")
to
=DMedian("Expr1";"qryDataAnalysisCenter")

Hope you have keep a copy for your original database :)

Inform about the error.
 

Mobiusrune

Registered User.
Local time
Yesterday, 19:37
Joined
Jan 7, 2013
Messages
28
Yes I have an original copy (and a backup).

For Text 132 I have tried it both ways and when I run the report the output is #Error. :banghead:
 

Users who are viewing this thread

Top Bottom