YES

B

Bean

The query presents sum for each month,which i have to evaluate the median
from

under a condition that the month's to show in the query

are only the month's that are before the month who presented on the form,

like this:

<[forms]![Ttichkoor_netoonim]![combo24]

when i canceling this, the function work.

but i need this condition.

how to combine the condition with the function ?

--
???? ???


Douglas J. Steele said:
Does the query have parameters? (Does it perhaps refer to a control on a
form?)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



???? ????? said:
thank you,

i get run-time error '3061'

too few parameters. expected 1.



--
???? ???


Douglas J. Steele said:
I don't see any reason why that shouldn't work.

When you say it doesn't work, what do you mean? Do you get an error? If
so,
what's the error? If you don't get an error, what do you get and what
do
you
think you should get instead?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Hello,

When i use this code on a table it is work,

but when i use it on a query it do'nt.

what should i do for using this code on query ? .....

Function Median (tName As String, fldName As String) As Single
Dim MedianDB As DAO.Database
Dim ssMedian As DAO.Recordset
Dim RCount As Integer, i As Integer, x As Double, y As Double, _
OffSet As Integer
Set MedianDB = CurrentDB()
Set ssMedian = MedianDB.Openrecordset("SELECT [" & fldName & _
"] FROM [" & tName & "] WHERE [" & fldName & _
"] IS NOT NULL ORDER BY [" & fldName & "];")
'NOTE: To include nulls when calculating the median value, omit
'WHERE [" & fldName & "] IS NOT NULL from the example.
ssMedian.MoveLast
RCount% = ssMedian.RecordCount
x = RCount Mod 2
If x <> 0 Then
OffSet = ((RCount + 1) / 2) - 2
For i% = 0 To OffSet
ssMedian.MovePrevious
Next i
Median = ssMedian(fldName)
Else
OffSet = (RCount / 2) - 2
For i = 0 To OffSet
ssMedian.MovePrevious
Next i
x = ssMedian(fldName)
ssMedian.MovePrevious
y = ssMedian(fldName)
Median = (x + y) / 2
End If
If Not ssMedian Is Nothing Then
ssMedian.Close
Set ssMedian = Nothing
End If
Set MedianDB = Nothing
End Function

THANKS A LOT
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Calculation for Median 3
median 31
Calculating the Median for specified groups 1
Calculating median in a group by query 4
Median in Report 1
Median in Report 1
Please help 6
Statistical Median Code 3

Top