Hi all,
I have the following problem which is driving me nuts and was wondering if anybody can point me in the right direction - please bear with me its quite a long one.
I have the following query (a20091)
this works fine and displays 2 columns, one with the ID (say 2) and one with countall number (say 8).
Now I also have this query (previous2009):
This displays 1 coumn with one number and works fine, in this case the number being 17.
Now I would like to place the above into vba.
I have this in vba:
I would like the program to find out which year we are in (year(now)) and then get the days remaining the from the previous year.
In this case year being 2009 and then the program runs the query previous2008 and grabs the figure from that query and adds it to string previous.
Now I would like the pc to know which year it is and then pick the correct query to run for the previous year, i.e. if it 2009 then run previous 2008, if 2010 then run previous2009.
Or can this be done automatically in vba without me making loads and loads of queries?
I hope this makes sense and any questions please ask, this is driving me nuts.
Thanks
Martin
I have the following problem which is driving me nuts and was wondering if anybody can point me in the right direction - please bear with me its quite a long one.
I have the following query (a20091)
Code:
SELECT holidaybookings.id, Count(holidaybookings.id) AS Countall
FROM holidaybookings
WHERE holidaybookings.id = forms!holidaymainbasic!child3!id AND holidaybookings.yearfld = 2009
GROUP BY holidaybookings.id;
this works fine and displays 2 columns, one with the ID (say 2) and one with countall number (say 8).
Now I also have this query (previous2009):
Code:
SELECT (entitlement.entitlementfld - a20091.Countall) AS daysremaining
FROM entitlement INNER JOIN a20091 ON entitlement.id =a20091.id
WHERE entitlement.id = forms!holidaymainbasic!child3!id AND entitlement.yearfld = 2009;
This displays 1 coumn with one number and works fine, in this case the number being 17.
Now I would like to place the above into vba.
I have this in vba:
Code:
If Year(Now) = "2009" Then
previous = DLookup("daysremaining", "previous2008")
End If
I would like the program to find out which year we are in (year(now)) and then get the days remaining the from the previous year.
In this case year being 2009 and then the program runs the query previous2008 and grabs the figure from that query and adds it to string previous.
Now I would like the pc to know which year it is and then pick the correct query to run for the previous year, i.e. if it 2009 then run previous 2008, if 2010 then run previous2009.
Or can this be done automatically in vba without me making loads and loads of queries?
I hope this makes sense and any questions please ask, this is driving me nuts.
Thanks
Martin