Would someone help make me a better coder?
I'm a beginner, and I was surprised that the following code works. However, I'm sure there is a more efficient method of doing this. The table is InvoiceE2021 which is a child table of Expenditures. I created a choice field called Month2021 which has 12 entries - Jan-Dec. When I select January I get a listing of all my 2021 expenditures for January. Is there anyone out there who can teach me a benter way of doing this?
if Month2021 = 1 then
 select InvoicesE2021 where year(Date) = 2021 and month(Date) = 1
else
 if Month2021 = 2 then
 select InvoicesE2021 where year(Date) = 2021 and month(Date) = 2
 else
 if Month2021 = 3 then
 select InvoicesE2021 where year(Date) = 2021 and month(Date) = 3
 else
 if Month2021 = 4 then
 select InvoicesE2021 where year(Date) = 2021 and month(Date) = 4
 else
 if Month2021 = 5 then
 select InvoicesE2021 where year(Date) = 2021 and month(Date) = 5
 else
 if Month2021 = 6 then
 select InvoicesE2021 where year(Date) = 2021 and month(Date) = 6
 else
 if Month2021 = 7 then
 select InvoicesE2021 where year(Date) = 2021 and month(Date) = 7
 else
 if Month2021 = 8 then
 select InvoicesE2021 where year(Date) = 2021 and month(Date) = 8
 else
 if Month2021 = 9 then
 select InvoicesE2021 where year(Date) = 2021 and month(Date) = 9
 else
 if Month2021 = 10 then
 select InvoicesE2021 where year(Date) = 2021 and month(Date) = 10
 else
 if Month2021 = 11 then
 select InvoicesE2021 where year(Date) = 2021 and month(Date) = 11
 else
 if Month2021 = 12 then
 select InvoicesE2021 where year(Date) = 2021 and month(Date) = 12
 end
 end
 end
 end
 end
 end
 end
 end
 end
 end
 end
end
3 replies
- 
  Code can be shortened: let m := Month2021; 
 select InvoicesE2021 where year(Date) = 2021 and month(Date) = mSteven 
- 
  Awesome Steven!! 
- 
  When I lived in Japan I always got where I wanted to go, but I'm certain I never took the shortest or best route. Wish they had gps back then. Thank you, Steven, for being my gps. Terrific! 
Content aside
- 4 yrs agoLast active
- 3Replies
- 224Views
