Second query in combo box not working

Sorry that all ran together. I have attached a word file with the results from the excel calculation.
 

Attachments

Those results are correct.

39, 45, 75
The middle number is 45, this is the median.

30, 75, 180, 1740
The middle numbers are 75 & 180. Exactly half way between these numbers (180 - 75 = 105, which is the difference between the numbers. 105/2 = 52.5, which is half the difference. 75+52.5 to put the lower boundery back makes it 127.5) is the median.
 
Yes, I understand that the results are correct. But I did not run the queries using my form. I just ran the queries by themselves.

When I use the form, it gives me the same answer for both queries. It is like it is not switching to the second query when it is selected or not clearing the maketable when the second query is trying to run. Or vice versa with the first query. :confused:
:eek:

I really need to make a 3 step "If, the, elseif" statement. I need to run the maketable query that is selected and then use the answer to calculate the median using the DMedian function. I don't know if this possible. There may be another statement that I do not know about.
 
Open the two make table queries which the combobox links to, then change the view to datasheet view.

One has the values "30, 75, 120" and the other has "39,75, 735".

Both will give a median of 75 if it is working correctly.

I'd advise adding / changing some data during testing to ensure the expected results can be identified.

However I did notice that in the latest upload from you the combobox's bound column is the real query name now so you should replace:
Code:
If Left(cmbQuery, Len(cmbQuery)) = "QUERY1" Then
DoCmd.OpenQuery "aqmakDoortoIVtPAStartInterval"
ElseIf Left(cmbQuery, Len(cmbQuery)) = "QUERY2" Then
DoCmd.OpenQuery "aqmakOnsettoDoorInterval"
End If
with
Code:
DoCmd.OpenQuery cmbQuery

This is because we are no longer having to check the ID / query number but can use the value of the combobox directly as an OpenQuery parameter.
 
:p I made the changes and added the code:
DoCmd.OpenQuery cmbQuery
and it works!!! It runs both of my queries from the form!!!!

Thank you soo much for all your help!!!!

Have a great rest of the day!!!
 
Well, I'm back.

I am now trying to use the same concept as before with the median but to calculate the average. I know that the average is a standard calculation by using the Totals function but I would like for it to resulted in a message box like the median.

I have attached the db. Any help would be greatly appreciated!! :)
 

Attachments

Users who are viewing this thread

Back
Top Bottom