Hi All
i hope this one is a simple one
I have a form that the user enters some information into and then a button to look up latest price for the input they have given and populate that on the form as well.
My price table looks like this:
The user inputs the following data
So in the code for the button matches customer, fruit, unit count and unit weight, but the issue i'm having is:
I'm not sure which one of those is the right way and i think i've tried a few different ways and it will work for 1 date input but not another, or if there are multiple records in the table for different dates there is different results, and i'm getting confused by the whole thing so thought i'd ask for someone's clarity who knows what it should be so i can go with that and test it in the different cases i have
thanks in advance
Glen
i hope this one is a simple one
I have a form that the user enters some information into and then a button to look up latest price for the input they have given and populate that on the form as well.
My price table looks like this:
Price Table | ||||||
Customer | Arrival Date | Fruit | Unit Count | Unit Weight (KG) | Selling Currency | Selling Price |
Cust1 | 29/10/2021 | Raspberries | 20 | 0.15 | EUR | 5 |
Cust1 | 05/11/2021 | Raspberries | 20 | 0.15 | EUR | 5.5 |
Cust1 | 12/11/2021 | Raspberries | 20 | 0.15 | EUR | 5.75 |
The user inputs the following data
User Input | ||||
Customer | Arrival Date | Fruit | Unit Count | Unit Weight (KG) |
Cust1 | 02/11/2021 | Raspberries | 20 | 0.15 |
So in the code for the button matches customer, fruit, unit count and unit weight, but the issue i'm having is:
- Should it be FindFirst or FindLast?
- Should it be Me.ArrivalDate <= Table.ArrivalDate or Table.ArrivalDate <= Me.ArrivalDate
Code:
sellPricesRS.FindLast "[Customer] = '" & delsCustomer & "' AND " & CSql(delsArrivalDate) & " <= [Arrival Date] AND [Fruit] = '" & delProdProduct & "' AND [Unit Count] = " & Me.del_prod_count & " AND [Unit Weight (KG)] = " & Me.del_prod_weight
sellPricesRS.FindLast "[Customer] = '" & delsCustomer & "' AND " [Arrival Date] <= " & CSql(delsArrivalDate) & " AND [Fruit] = '" & delProdProduct & "' AND [Unit Count] = " & Me.del_prod_count & " AND [Unit Weight (KG)] = " & Me.del_prod_weight
sellPricesRS.FindFirst "[Customer] = '" & delsCustomer & "' AND " & CSql(delsArrivalDate) & " <= [Arrival Date] AND [Fruit] = '" & delProdProduct & "' AND [Unit Count] = " & Me.del_prod_count & " AND [Unit Weight (KG)] = " & Me.del_prod_weight
sellPricesRS.FindFirst "[Customer] = '" & delsCustomer & "' AND " [Arrival Date] <= " & CSql(delsArrivalDate) & " AND [Fruit] = '" & delProdProduct & "' AND [Unit Count] = " & Me.del_prod_count & " AND [Unit Weight (KG)] = " & Me.del_prod_weight
I'm not sure which one of those is the right way and i think i've tried a few different ways and it will work for 1 date input but not another, or if there are multiple records in the table for different dates there is different results, and i'm getting confused by the whole thing so thought i'd ask for someone's clarity who knows what it should be so i can go with that and test it in the different cases i have
thanks in advance
Glen