Solved Code_Automation (1 Viewer)

Alejo

Member
Local time
Today, 13:55
Joined
Jun 14, 2021
Messages
78
Good Day to all,

I would like to request your assistance to the below query.

Attached is my sample DB. In the form below, there are AVG_Cust automated value from Customers.
I need that the third column will have an automated value based on the value from AVG_Cust. As per below sampe if the value is 19.5 the Result Column should automatically display "Very good"....etc....

AVG_Cust Result
less than 20 >>>>>> Very good
Equal to 20 >>>>>> Good
More than 20 >>>>>> Poor

1670054715063.png
 

Attachments

  • Database1.6.accdb
    480 KB · Views: 85

amorosik

Member
Local time
Today, 12:55
Joined
Apr 18, 2020
Messages
397
On third textbox you must insert a call to function for example =my_result(txtAvgCust)
Then on the code

Function my_result(byval valore as double) as string
If valore < 20 then my_result="Very Good"
If valore = 20 then my_result="Good"
If valore > 20 then my_result="Poor"
End

Or Select Case
 

ebs17

Well-known member
Local time
Today, 12:55
Joined
Feb 7, 2020
Messages
1,949
It's a good idea to perform the calculation in a query and display the query results in bound fields on the form.
SQL:
SELECT
   Customer,
   AVG(Prep_date) AS AVG_Cust,
   Switch(AVG_Cust < 20, "Very good", AVG_Cust = 20, "Good", AVG_Cust > 20, "Poor") AS Descr
FROM
   Table1
WHERE
   Product = "A"
      AND
   Class_Type = "M"
      AND
   D_Date > #9/1/2022#
      AND
   D_Date < #9/1/2023#
GROUP BY
   Customer
 

Alejo

Member
Local time
Today, 13:55
Joined
Jun 14, 2021
Messages
78
Hi ebs17,

Thanks for your response.

I'm not expert and can't transfer the SQL into my DB.
May I request you to put it into the attached DB and send back to me. This way I can interpret.
Thank you
 

ebs17

Well-known member
Local time
Today, 12:55
Joined
Feb 7, 2020
Messages
1,949
Are you aware that I created the query in the database you provided?
 

Alejo

Member
Local time
Today, 13:55
Joined
Jun 14, 2021
Messages
78
Are you aware that I created the query in the database you provided?
hI ebs,

Perfect, got it now.

I was bit confused when I saw the SQL format codes.

Thank you very much. Subject query closed.
 

Users who are viewing this thread

Top Bottom