Query top % of value possible??

Thank you, Markk! Can I ask you one more favor? Can you help me understand what 'sum + !Value' is doing? I can see this is the piece that's accumulating the values, but I guess I have no idea what !Value is?
 
snueberg, Markk, I can't thank you enough for all your time helping me with this! I still need to incorporate what Mark's designed, but I'm very confident in being able to do that. I really appreciate your help, you guys are awesome!
 
!Value is short for rst!Value and is the value of the Value field from the query

Code:
"SELECT * FROM Table1 ORDER BY Value DESC"

and so is the value of the Value field in Table1. This is inside a loop where the record set rst visits all of the records in descending order of Value.

If you put
Code:
Debug.Print !Value

in the code you can see what's going on in the Immediate window.
 
Thanks Steve. Did you get that Sue? Lots of people recommend not using Value as a field name, and you can see I've broken that rule here. Sorry if was confusing. But does it all make sense?
 
I'm really close! I have it built and it works!!!!! Yay!!

Now, I can't figure out how to call it. It doesn't show as a macro, except in the VB module itself, so a user can't get to it. I'd like to put a macro to clear the old data, append new and then call this procedure, but I don't know how to call the procedure. Everything else is done and working.
 
If it's in a standard module like Mark had it and you want to call it in a macro you will need to change it from a sub to a function. Just change Sub to Function at the beginning. Access will change End Sub to End Function for you. Then in your macro you will use RunCode to call it. When you start typing the function name Intellisense will try to help you out but it can mess you up. For example in Mark database if I start typing FindTop80Percent you should see it appear but if you select it will add it as

FindTop80Percent(

which is missing the closing parenthesis. So just remember to complete it like

FindTop80Percent()
 
It works, it works, it works!

Over the years, I've actually worked around providing something like this, I'm so excited to know how to do it now!!

Thank you both very much!!!!!!
 

Users who are viewing this thread

Back
Top Bottom