View Full Version : Change Top N based on table


jnixon
08-12-2005, 01:36 PM
Well hello everyone. I'm building some queries that need to have a specific Top N amount read from a value in a table (or form). Can someone please tell me how to do that without using the query Top N drop-down? I have this built into a VBA module, so it's possible I can change the Top N from there. Thanks!

jnixon
08-12-2005, 01:54 PM
By the way, here's the very simple VBA code I have now...
DoCmd.DeleteObject acTable, "CompsReturned"
DoCmd.OpenQuery "05 Comps Returned Lvl 1", acNormal, acAdd
If DCount("[ID]", "CompsReturned") < DMax("[Total Comps Needed]", "Comp Qualifiers") Then
DoCmd.OpenQuery "08 Append Addtl Comps Lvl 2", acNormal, acAdd
End If
If DCount("[ID]", "CompsReturned") < DMax("[Total Comps Needed]", "Comp Qualifiers") Then
DoCmd.OpenQuery "11 Append Addtl Comps Lvl 3", acNormal, acAdd
End If
DoCmd.OpenQuery "13 Comps Returned Final", acNormal, acAdd

Thanks in advance!

jnixon
08-15-2005, 08:03 AM
Never mind, found my answer here:
http://www.access-programmers.co.uk/forums/showthread.php?t=39442