1
So, I have 6 queries and I want to run them all once at the end of each month. (I know a bit about SQL but they're simply built using Access's design view). So, in the next few days, perhaps I'll run the 6 queries for May, as May just ended. I only want the data from the month that just ended, so the query has Criteria set as the name of the month (e.g., May). Now, it's not hugely time consuming to change all of these each month, but is there some way to automate this? Currently, they're all set to April and I want to change them all to May when I run them in a few days. And each month, I'd like to type the month (perhaps in a textbox in a form or somewhere else if you know a better way) just once and have it change all 6 queries, without having to manually open all 6, scroll over to the right field and change the Criteria.
Note (about VBA): I have used Excel VBA so I know the basics of VBA but I don't really know anything specific to Access (other than seeing code a few times). And, others will use this who do not know anything about Access VBA. So, I think I have found a similar question/answer that could do this in VBA, but I'd rather do it some other way. If the query needs to be slightly redesigned later, probably by someone who doesn't know Access VBA at all, it'd be nice to have a solution not involving VBA if that is even possible.
Dave, thanks for the detailed answer. Your last paragraph talks about the "final step". This is what I really need help with. Based on the link I provided in my question, I know I could change the criteria by putting the entire SQL statement in my code and putting a variable in there, probably getting its value from a textbox on a form. My question is, essentially, is there an easier way (easier than using the SQL in VBA) to do this "final step". Is there some sort of setting like Queries("Query1").Field("Month").Criteria = "May"? – Graphth – 2012-06-04T14:35:18.860
Yes, there is an easier way. You don't need to put the SQL in the VBA code. I will edit my answer to show you how. – Dave Becker – 2012-06-04T17:51:51.720
@Graphth - Is this the answer you were looking for? – Dave Becker – 2012-06-06T13:54:23.073
Perhaps, will have to wait until I have a chance to try it out. – Graphth – 2012-06-06T17:30:36.557
@Graphth - Did this work for you? – Dave Becker – 2012-06-18T15:59:12.447
@Graphth - Have you had a chance to try this? I hope it's the answer to your question! – Dave Becker – 2012-06-28T03:32:53.380