Use Macro Buttons to Run Different Queries against a Subform's Data

chip0105

Registered User.
Local time
Today, 04:50
Joined
Sep 12, 2014
Messages
19
Perhaps this will help to explain what I am trying to do. Please read through all of this post as the end might be easier to respond to than each of the individual processes I list:
On my form, I currently have macro buttons that filter my subform for “Complete” and “Incomplete” projects. I am trying to add a few more macro buttons on my main form to filter my subform data as listed below:

VBA Macro process for “Due Between Dates”
In my subform I have a [DueDate] field.

I need to filter my subform source data by a specific date range entered by the user.

The user should be able to enter their desired beginning [DueDate] and ending date [DueDate] values within a pop-up window. Similar to the “Between” function: Between [Enter Beginning Due Date] and [Enter Ending Due Date].

The results will filter all records in the subform, between the dates specified.

VBA Macro process for “Early/On-Time”
In my subform I have a [DueDate] field. I want to find project records that are not past due as well as the records that have not been completed late.

So, I need to filter records where the [DueDate] <= Date() and the [CompletionDate] <> Null

AND
I also need to include any records where the [CompletionDate] < [DueDate].

VBA Macro process for “Late”
In my subform I have a [DueDate] field. I want to find project records that are past due as well as the project records that have not been completed on time.

So, I need to filter records where the Date() > [DueDate] and the [CompletionDate] = Null

AND

I also need to include any records where the [CompletionDate] < [DueDate].

Note: I created separate individual queries to perform these functions and the queries provide the exact data I am looking for. However, I cannot figure out how to have my VBA code change my SouceObject/Master/Child fields to another query source, then use a another macro button to change my SouceObject/Master/Child fields back to their original settings for other form functions to work as coded.
:banghead: Any assistance would be greatly appreciated!!
 
Please read through all this....

I didn't... Why not? I went and looked for a less verbose post, a post where I could quickly see if I had something to offer.

Why am I telling you this?

I see many verbose posts and I skip those too. I bet most others here do the same.

In other words, your are more likely to receive a helpful answer if you break your problem down in to smaller problems.

And if you think about it, that's the essence of good programming practice, build your code in small easily tested components, called functions/subroutines.

It's true even for SQL statements. I see many SQL statements that are LONG complicated barely readable, posted here in the hope that a more experienced eye can spot the problem.

I checked through one for an OP recently and what did I do? I copied it in to a module, tidied it up as per good programming practice's and the problem was plain to see.

I'm sure if I read your post I could ferret out the essence of your problem, but I didn't even attempt to read it, and that's what I wanted to bring to your (and anyone else's) attention, a short clear post focused on one issue is very likely to be answered. A longer less precise question, or multiple questions, in one, less likely to be answered.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom