Macro filter on query

I need to run 8 append and update queries using the same date range. I 
created a Form with the "Month" field  as the filter and a command button to 
run the macro to run the Append & Update queries for records in the month 
range. I can't get the Apply Filter macro to work on the Query Date field. 
Any suggestions?
0
Utf
11/3/2007 12:15:00 PM
access 16762 articles. 2 followers. Follow

4 Replies
1698 Views

Similar Articles

[PageSpeed] 43

Apply Filter action will not do what you seek.

Your queries must have a WHERE clause that refers in some way to the textbox 
on the form where you've entered the Month value/data that you want to use 
in the queries.

To assist you further, you need to post the SQL statements of a few of 
queries so that we can see what the queries are intending to do, and tell us 
what type of data you type into the Month textbox on the form (month name, 
e.g., January, Feb, etc.; or month number, e.g., 1, 2, 3, etc.), and how you 
want to use this value in the queries.
-- 

        Ken Snell
<MS ACCESS MVP>



"LJS" <LJS@discussions.microsoft.com> wrote in message 
news:5E0F2BA7-144C-40C9-AC0F-78E7C93C17EA@microsoft.com...
>I need to run 8 append and update queries using the same date range. I
> created a Form with the "Month" field  as the filter and a command button 
> to
> run the macro to run the Append & Update queries for records in the month
> range. I can't get the Apply Filter macro to work on the Query Date field.
> Any suggestions? 


0
Ken
11/3/2007 3:40:22 PM
Daily data in the transaction files has been summed with the query
INSERT INTO LedgerAccounts ( Type, [Date], AcctNo, Debit, Credit )
SELECT ExpenseLedger.Type, Format([Date],"mmm yy") AS Exp1, 
ExpenseLedger.AcctNo, Sum(ExpenseLedger.Debit) AS SumOfDebit, 
Sum(ExpenseLedger.Credit) AS SumOfCredit
FROM ExpenseLedger
GROUP BY ExpenseLedger.Type, Format([Date],"mmm yy"), ExpenseLedger.AcctNo, 
ExpenseLedger.Posted;

3 other similar queries for other daily data have also been produced. Using 
a Form with an unbound property field [Enter Month] with a "mmm yy" format 
and a text box named "txtQueryFilter" with statement 
=Forms![PostingToG/L]![Enter Month]. A command button on the form would run 
the 8 queries. I am trying to get the queries to see the Form [Enter Month] 
field so that all queries will run by macro using the same [Enter month] 
value ie “Oct 07”

 	After running the 4 queries I need to run 4 Update queries on the source 
tables to confirm the data for the time period has been transferred. The 
Update queries are :
UPDATE ExpenseLedger SET ExpenseLedger.Posted = Yes
WHERE (((ExpenseLedger.Posted)=No));

The query needs to know the Form [Enter Month] value that was used for the 
Append queries.

What do I have do to get the queries to recognize the [Enter Month] value on 
the Form?

Thanks



"Ken Snell (MVP)" wrote:

> Apply Filter action will not do what you seek.
> 
> Your queries must have a WHERE clause that refers in some way to the textbox 
> on the form where you've entered the Month value/data that you want to use 
> in the queries.
> 
> To assist you further, you need to post the SQL statements of a few of 
> queries so that we can see what the queries are intending to do, and tell us 
> what type of data you type into the Month textbox on the form (month name, 
> e.g., January, Feb, etc.; or month number, e.g., 1, 2, 3, etc.), and how you 
> want to use this value in the queries.
> -- 
> 
>         Ken Snell
> <MS ACCESS MVP>
> 
> 
> 
> "LJS" <LJS@discussions.microsoft.com> wrote in message 
> news:5E0F2BA7-144C-40C9-AC0F-78E7C93C17EA@microsoft.com...
> >I need to run 8 append and update queries using the same date range. I
> > created a Form with the "Month" field  as the filter and a command button 
> > to
> > run the macro to run the Append & Update queries for records in the month
> > range. I can't get the Apply Filter macro to work on the Query Date field.
> > Any suggestions? 
> 
> 
> 
0
Utf
11/4/2007 2:33:00 AM
I've been out of town for the past four days. I'll post a reply later today 
or tomorrow; sorry for the delay.

-- 

        Ken Snell
<MS ACCESS MVP>


"LJS" <LJS@discussions.microsoft.com> wrote in message 
news:7988EAEE-B402-4AC9-A2DD-09EBABF3D4A6@microsoft.com...
> Daily data in the transaction files has been summed with the query
> INSERT INTO LedgerAccounts ( Type, [Date], AcctNo, Debit, Credit )
> SELECT ExpenseLedger.Type, Format([Date],"mmm yy") AS Exp1,
> ExpenseLedger.AcctNo, Sum(ExpenseLedger.Debit) AS SumOfDebit,
> Sum(ExpenseLedger.Credit) AS SumOfCredit
> FROM ExpenseLedger
> GROUP BY ExpenseLedger.Type, Format([Date],"mmm yy"), 
> ExpenseLedger.AcctNo,
> ExpenseLedger.Posted;
>

< snipped > 


0
Ken
11/9/2007 6:57:49 PM
I'm not fully understanding exactly which queries should look to the form's 
textbox for the "mmm yy" value, but here is a generic query that would do 
this:

SELECT Field1, Field2, Field3
FROM TableName
WHERE Field1 = [Forms]![PostingToG/L]![Enter Month]

Does this help you in identifying how to add this WHERE clause to the 
queries?

-- 

        Ken Snell
<MS ACCESS MVP>



"LJS" <LJS@discussions.microsoft.com> wrote in message 
news:7988EAEE-B402-4AC9-A2DD-09EBABF3D4A6@microsoft.com...
> Daily data in the transaction files has been summed with the query
> INSERT INTO LedgerAccounts ( Type, [Date], AcctNo, Debit, Credit )
> SELECT ExpenseLedger.Type, Format([Date],"mmm yy") AS Exp1,
> ExpenseLedger.AcctNo, Sum(ExpenseLedger.Debit) AS SumOfDebit,
> Sum(ExpenseLedger.Credit) AS SumOfCredit
> FROM ExpenseLedger
> GROUP BY ExpenseLedger.Type, Format([Date],"mmm yy"), 
> ExpenseLedger.AcctNo,
> ExpenseLedger.Posted;
>
> 3 other similar queries for other daily data have also been produced. 
> Using
> a Form with an unbound property field [Enter Month] with a "mmm yy" format
> and a text box named "txtQueryFilter" with statement
> =Forms![PostingToG/L]![Enter Month]. A command button on the form would 
> run
> the 8 queries. I am trying to get the queries to see the Form [Enter 
> Month]
> field so that all queries will run by macro using the same [Enter month]
> value ie "Oct 07"
>
>  After running the 4 queries I need to run 4 Update queries on the source
> tables to confirm the data for the time period has been transferred. The
> Update queries are :
> UPDATE ExpenseLedger SET ExpenseLedger.Posted = Yes
> WHERE (((ExpenseLedger.Posted)=No));
>
> The query needs to know the Form [Enter Month] value that was used for the
> Append queries.
>
> What do I have do to get the queries to recognize the [Enter Month] value 
> on
> the Form?
>
> Thanks
>
>
>
> "Ken Snell (MVP)" wrote:
>
>> Apply Filter action will not do what you seek.
>>
>> Your queries must have a WHERE clause that refers in some way to the 
>> textbox
>> on the form where you've entered the Month value/data that you want to 
>> use
>> in the queries.
>>
>> To assist you further, you need to post the SQL statements of a few of
>> queries so that we can see what the queries are intending to do, and tell 
>> us
>> what type of data you type into the Month textbox on the form (month 
>> name,
>> e.g., January, Feb, etc.; or month number, e.g., 1, 2, 3, etc.), and how 
>> you
>> want to use this value in the queries.
>> -- 
>>
>>         Ken Snell
>> <MS ACCESS MVP>
>>
>>
>>
>> "LJS" <LJS@discussions.microsoft.com> wrote in message
>> news:5E0F2BA7-144C-40C9-AC0F-78E7C93C17EA@microsoft.com...
>> >I need to run 8 append and update queries using the same date range. I
>> > created a Form with the "Month" field  as the filter and a command 
>> > button
>> > to
>> > run the macro to run the Append & Update queries for records in the 
>> > month
>> > range. I can't get the Apply Filter macro to work on the Query Date 
>> > field.
>> > Any suggestions?
>>
>>
>> 


0
Ken
11/11/2007 3:47:01 AM
Reply:

Similar Artilces:

Macro warning with no macros
I have a workbook that when I try to open it I get the warning tellin me it contains macros and asking whether I want to Enable or Disabl them. I put no macros, no VB scripts, nothing at all in the workboo other than standard Excel formulas and some charts. I developed it i Excel 2002, SP-2, but have moved it back and forth between tw computers, the other which has Excel 97. Regardless of whether Enable or Disable or change the security settings so as not to get th warning, once the workbook is open even if I go t Tools-Macro-Macros... it lists no macros. How can I find out what's cau...

Database Query #3
I posted this earlier with no replies. Anyone got any ideas? I am using a database query to retrieve data from another database excel file. The problem I am having is that the column of data which I have contains records which have both text and number formats. When the data transfers, it only brings those records which are number format. Is there any way to make is so that the database query will pull both number and text formats, as I can't easily change it so that it is one or the other? Thanks The following article in Dick Kusleika's web log may help: http://www.di...

Macro
Can anybody tell me how to kick off a macro automatically as file is opened? Regards ...

Macro
Version: 2008 Operating System: Mac OS X 10.4 (Tiger) Processor: intel Hi, I'm thinking of buying Mac: Office 2008, but before I do I want to check that I will be able to download Scritpsmart collection of templates without any glitches: <http://www.bbc.co.uk/writersroom/scriptsmart/faq.shtml> Does anyone know if I can do this? Regards, SP. In article <ee98ff5.-1@webcrossing.caR9absDaxw>, StregaItalia@officeformac.com wrote: > Version: 2008 > Operating System: Mac OS X 10.4 (Tiger) > Processor: intel > > Hi, > > I'm thinking of buying Mac: Of...

Run macro automatically.
How do I make a macro run automatically when a worksheet it is attached to is loaded? right click on the sheet tab>view code>left window worksheet>right window activate -- Don Guillett SalesAid Software donaldb@281.com "Excel macro" <Excel macro@discussions.microsoft.com> wrote in message news:DD7AF1E3-9263-4523-AC49-A43ABA1AB9D0@microsoft.com... > How do I make a macro run automatically when a worksheet it is attached to is > loaded? I am unable to find "activate " when I right click on worksheet. ( i assume that you are referring to the windo...

Help with macro/and or formula?
Perhaps this is a silly question, but i just can't figure out how t format this worksheet. The problem is that a lot of the cells hav numbers in them with negative signs in the back instead of in the fron (ie. 23-) and i was wondering if anyone knew of a macro/formula i coul use to quickly fix this problem for all the cells. I would b extremely grateful. Thanks -- brefed1 ----------------------------------------------------------------------- brefed15's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=3557 View this thread: http://www.excelforum.com/showthre...

Attached Toolbars Macros
Excel 2003 I have a custom tool bar, this tool bar has several items, each item is pointing to a VBA code. This tool bar is attached to the worksheet. I've copied this spreadsheet to several computers. After I copied the spreadsheet I decided to rename the spreadsheet, after I renamed the spreadsheet the Toolbar Item's macros were still pointing to the old name, I reasigned each tool bar item to the current spreadsheet, saved the spreadsheet and everything was working on my computer, but when I re-copied the new spreadsheet to other computers and I clicked on the Toolbar Item...

Protected sheets and running macros
i have a sheet with a macro ran by a normal button at the top. Howeve when i protect the worksheet where ever i click on the sheet the macr executes. Can any one offer any advice on how to stop this? Thanks Robert -- Message posted from http://www.ExcelForum.com hi, i am not able to reproduce the problem, hence i may not be able t provide a panacea for that issue. here is what i suggest. i have a sheet that has a macro that is run when a control toolbo button (that is, not a form button) is clicked. this sheet is protected based on the user logged in. what i have don is to protect t...

Sum of Two Union Queries
Hello, I have the following SQL that produces two record totals (as it should). But I want to SUM those two values from within the same query. Rather than create a second query that SUMs the two values from the first query: SELECT Count(*) AS SubCount FROM [MyTable1] WHERE (([MyTable1].UNIQUEUSER)="JOHNSMITH") UNION ALL SELECT Count(*) AS SubCount FROM [MyTable2] WHERE (([MyTable2].SWCASSIGNEDUSER)="JOHNSMITH"); The results I get are: SubCount -------------- 380 2 I've tried "wrapping" that entire SQL code inside of a SELECT SUM, but upon execution it ...

Macro to remove rows?
Hi, I receive thousands of rows of data from an extract that comes from a database. The data extract automatically generates page headers that need to be removed, and I would love to automate this process. The headers do have a pattern to them, but I'm not clever enough to figure out a good way to use that to write a macro. The first row of the header starts with hyphens ------------------------------- Then there's a variable number of rows of header data to delete followed by another row of hyphens ------------------------------- Then 2 additional rows that must be deleted. The nu...

Macro Freezes Reading Pane
I have a macro that Sends/Receives Tasks from Project Server into Outlook Tasks. Everything is working fine, except one weird thing that happens. I have the Timer set on the macro and it starts as soon as Outlook starts. The macro gets the tasks from ProjectServer every hour. As soon as the macro starts running the Reading pane freezes in the Inbox. If i stop the macro then Reading pane is back to normal. Can anyone please tell me if there is something I can do in VBA to fix this annoying issue. Thanks a lot ...

Calling on a macro within a macro!
Hey All!! Quick Question - How do you call up a macro within a current macro? I have one big macro and I need it to jump to several other macros when it runs! Does it matter where the other macros are stored or is it better to have them all in one module? Help appreciated Thnx! Hi Mellowe, '=============>> Public Sub Main() 'Your code Call One 'your code End Sub '<<============= '=============>> Public Sub One() MsgBox "Hi from One" End Sub '<<============= > Does it matter where the other macros are stored or ...

shortcut keys to macros
Hi, Is it at all possible to assign shortcut keys to macros in Outlook? Thx, Hans ...

help Unable to record Macro !!!!!!!
I want to record a macro in excel.But as soon as I click record Macro it says "unable to record" macro. Got no help in excel help.I do this same thing in word and it's working. Please help It's urgent for me !!!1 Have a look here http://groups.google.com/groups?as_epq=unable%20to%20record&as_ugroup=microsoft.public.excel.* -- Don Guillett SalesAid Software donaldb@281.com "ash" <anonymous@discussions.microsoft.com> wrote in message news:3e0b01c42ae5$45333e00$a401280a@phx.gbl... > I want to record a macro in excel.But as soon as I click > record...

Macro that password protects a sheet
I am attempting to create a macro that can open a protected sheet, change something, and then protect it again. I continue to have an issue with the macro not entering the password. Is this possible to do/fix? Thanks, Ryan ..open password="mypassword" -- Don Guillett SalesAid Software donaldb@281.com "Ryan" <Ryan@discussions.microsoft.com> wrote in message news:D4780ED8-CA1D-4284-97BC-3576160D998E@microsoft.com... > I am attempting to create a macro that can open a protected sheet, change > something, and then protect it again. I continue to have an iss...

Footer Macro?
Hi Months ago I read a Public Sub Macro that read the selection of a drop down list in a combo box and placed it in the center Footer at the same time it also placed the date in the right Footer and tme in the left footer. I have searched most of the regular sites including this one and cannot find it anywhere --- Can anyone help with my search. Any help much appreciated Cheers ---- Mully ...

Connection Filtering #5
Hi, I have a question regarding Exchange 2003 Server Connection Filtering configuration. I have added an IP address to allow exchange 2003 server to accept email; but then I started to get spams coming from the IP address. My question is how can I only set up a particular email address from that IP address so that exchange server will allow through but not allow other emails from other addresses from this IP to come in? Please provide me a step by step on the configuration. I am fairly new and not an expert. Many Thanks ...

filtering a list by row color
Hi all, I have a data set, that I used conditional formatting on to highlight rows where there were certain values found in any of 4 columns. That works fine, but now what I want to do is filter the big list, so I can print out ONLY the rows that have been colored. I cannot see a way to do that with autofilter, does anyone else know how I could do that? Thanks Mike You won't with autofilter I am afraid. You will need to create a helper column with the CF test in it, and filter on the TRUE values. -- HTH RP (remove nothere from the email address if mailing direct) <michael_n...

Keyboard Shortcut in Macro
Hi all i'v created macro with Keyboard Shortcut Ctrl+b . now i want to change it to Ctrl+z how can i do it . regards Tools-->Macro-->Macros. Select (don't open!) your macro, and hit the Options button. :) ************ Hope it helps! Anne Troy www.OfficeArticles.com "osaka78" <osaka78@discussions.microsoft.com> wrote in message news:1721A458-212D-4446-8209-494A459EE428@microsoft.com... > Hi all > i'v created macro with Keyboard Shortcut Ctrl+b . now i want to change it > to > Ctrl+z > how can i do it . > > regards THE MACRO IS NO...

Macros have been disabled but there is no macro
when I open a specific doc the info bar at the top says "Macros have been disabled", but when I hit Alt+F11 I can't find any VB or a module to remove. Why is it telling me about macros? Other docs don't give me this prompt. I thought I might have to enable macros to see the code. When I enabled macro, it said "do you want to save changes to this doc?" it flickered and came back as if immediately reopened. Any ideas? I could copy and paste the text into a new doc but I'd be interested to be able to strip off this problem. The doc is an internal IT ...

Startup macro
Is it possible for automatic start of macro in moment when excel file is opening. I mean when I open excel file specific macro will be immediately automatic started. Zeno option explicit sub auto_Open() call yourspecificmacronamehere end sub Zeno wrote: > > Is it possible for automatic start of macro in moment when excel file is > opening. > I mean when I open excel file specific macro will be immediately automatic > started. > > Zeno -- Dave Peterson ...

Excel 2004 crashes on update/insert/load query
I've tried sending update and insert queries and a load data local command via a query table. It's a bit hack, but I don't see another way. This results in a hard crash of Excel. I'm running Excel 2004 (PPC MAC, OS X 10.4) and mysql (similar problem w/ another database). Here's the code: Sub foo() connstring = "ODBC;DSN=mstestmysql5;UID=tlg;PWD=4756;Database=mstest;OPTION=65539" sqlstring = "LOAD DATA LOCAL INFILE '/Users/Shared/bar.txt' INTO TABLE tFirstPassEstimates" With Worksheets(1).QueryTables.Add(Connection:=connstring, _ D...

Filtering reports
Advice sought on filtering reports. Learner needs pointing in the right direction!! Can someone please give me some help with printing out reports, in my case invoices? I have some customers that I invoice “On Delivery” and other customers that are invoiced at month end. My question is what is the simplest way to filter out deliveries that have already been invoiced so that I can create batch invoices at the month end. I have inherited this system and do not wish to change it. I can print out Delivery Notes and Invoices from an orders form I created and if I go into my Invoice report I ...

Run multiple Macros or macros from within other macros ?
I would like to run multiple macros at startup. What code should be used in the Private Sub Application_Startup command in the ThisOutlookSession area ? If the names of my macros were below what would the code to look like ? Macro1 Macro2 Macro3 I have looked at the samples from previous posts and cannot determine how to make them apply specifically to my needs. In Excel you can use the Run "Macro1" line and it would run that macro. Run does not work in Outlook I suppose because I kept getting an error. **** Also - What code is needed to execute a macro from w...

Filter based on unbound text box with default value
I'm using the fOSUserName module to give an unbound text box a default value of the user's network User Name. I'm trying to filter a form using this text box value (Text24), as this value corresponds to a bound field (Anumber) in the form's driving query. I cannot seem to get it to all come together. I used the below code, but, when run, it throws up a dialog box which has the unbound text box's value in it. If I enter that value in the dialog box, the form filters as I want it too. Hope that makes sense....thanks for any help. Dim strFilter As String strFilter = &...