DLookup based on Average, no result (1 Viewer)

SarahNorth

New member
Local time
Today, 12:22
Joined
Apr 11, 2019
Messages
7
I have created a report that has averages for some groupings. I then use DLookup to retrive marks assaigned to those specific averages from another table. The correct result only shows for the last record on the report. It is as if the result from =Avg() is calculated after the field with the DLookup function executes. If I use a field withouth a calculation to test my DLookup function everything works out fine.
How can I force one calculation to be completed before another or how to I get Access to execute the DLookup function after a second or even put that code behind a button.
I want to use the average in the report to look up the primary key in another table and then return what is in the field corresponding to that ID into a text field.
Help please
 

isladogs

MVP / VIP
Local time
Today, 05:22
Joined
Jan 14, 2017
Messages
18,209
I've read this several time but am struggling to understand how the different parts link together. Th fact that there have ben almost 20 views with no other replies may indicate I'm not alone.
Please try explaining again and add screenshots or attach your db. Zip first as you have less than ten posts.
 

SarahNorth

New member
Local time
Today, 12:22
Joined
Apr 11, 2019
Messages
7
OK I will try to explain better.
The first attachment shows the report and how the fields I want to show to display my DLookup result are empty and the second attachment shows my DLookup. It is as if the Average function on which the DLookup relys on doesn't get calculated until after the DLookup. Do I have to create a temporary table or can I use an event to force the report to populate the fields. Still, help please!:banghead:
 

Attachments

  • Database.jpg
    Database.jpg
    22.3 KB · Views: 186
  • Database2.jpg
    Database2.jpg
    7.5 KB · Views: 188

isladogs

MVP / VIP
Local time
Today, 05:22
Joined
Jan 14, 2017
Messages
18,209
Yes I can see why it wouldn't work reliably.
You're trying to look up values using criteria that aren't stored data.
Suggest you use an aggregate query to calculate the averages.
Then base your DLookup on that query rather than just the table.
That way you know the averages are calculated first
 

isladogs

MVP / VIP
Local time
Today, 05:22
Joined
Jan 14, 2017
Messages
18,209
Excellent. Good luck with the rest of your project.
 

Users who are viewing this thread

Top Bottom