Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22
  1. #16
    hapm is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    197
    Simply add a condition to your querys: ... AND (IsNull([Forms]![YourFormsName]![inputDate]) OR [Forms]![YourFormsName]![inputDate] <= [YourTablesDateFieldName])
    Don't miss the brackets because AND has precedence over OR and you don't want that here.

  2. #17
    Ace2014 is offline Advanced Beginner
    Windows XP Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    88
    Quote Originally Posted by hapm View Post
    Simply add a condition to your querys: ... AND (IsNull([Forms]![YourFormsName]![inputDate]) OR [Forms]![YourFormsName]![inputDate] <= [YourTablesDateFieldName])
    Don't miss the brackets because AND has precedence over OR and you don't want that here.
    Cool, thanks.

    So I on my form with the inputDate selected, I chose the Event:After Update
    I used the expression builder and entered:
    Code:
    = SELECT 
    FROM [qry1_PartPricingAggregation]
    AND (IsNull([Forms]![SelectScope]![inputDate]) 
    OR ([Forms]![SelectScope]![inputDate] <= [qry1_PartPricingAggregation].[Date])
    And I got this error

    Click image for larger version. 

Name:	error.JPG 
Views:	5 
Size:	22.2 KB 
ID:	16840

  3. #18
    hapm is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    197
    The code I gave you is SQL. You should add it to the where clause of the query that is filtered by your comboboxes. No need to add any vba code or event macro here.

  4. #19
    Ace2014 is offline Advanced Beginner
    Windows XP Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    88
    I don't know how to do that. I'm not sure I understant it either.

    So I opened up my query in which the report is based off of.

    I highlighted the Date field in red.
    So in it's place it should read:

    Code:
    FROM [tbl1_PartPricingDataAggregation.Date]
    Where 
    AND (IsNull([Forms]![SelectScope]![inputDate]) 
    OR ([Forms]![SelectScope]![inputDate] <= [tbl1_PartPricingDataAggregation.Date]
    Query sql:

    Code:
    SELECT 
    tbl3_HierarchySeg.L1, 
    tbl3_HierarchySeg.L2, 
    tbl3_HierarchySeg.L3, 
    tbl2c_PartneoClientAcc.Client, 
    tbl2b_PartneoSeg.PFC, 
    tbl2b_PartneoSeg.PFN, 
    tbl2b_PartneoSeg.PSFC, 
    tbl2b_PartneoSeg.PSFN, 
    tbl2a_PPNCharacteristics.PartStatus, 
    tbl2a_PPNCharacteristics.Competitivity, 
    tbl2a_PPNCharacteristics.PNDescription, 
    tbl2a_PPNCharacteristics.PivotPart, 
    tbl2a_PPNCharacteristics.PPN, 
    tbl1_PartPricingDataAggregation.PNAggregation, 
    tbl1_PartPricingDataAggregation.Brand, 
    tbl1_PartPricingDataAggregation.Price, 
    tbl1_PartPricingDataAggregation.Currency, 
    tbl1_PartPricingDataAggregation.Market, 
    tbl1_PartPricingDataAggregation.Range, 
    tbl1_PartPricingDataAggregation.Date, 
    tbl1_PartPricingDataAggregation.MatchStatus, 
    tbl1_PartPricingDataAggregation.Comments, 
    tbl1_PartPricingDataAggregation.Source, 
    tbl1_PartPricingDataAggregation.Photo
    FROM 
    (tbl1_PartPricingDataAggregation 
    LEFT JOIN (tbl2a_PPNCharacteristics 
    LEFT JOIN (tbl2b_PartneoSeg 
    LEFT JOIN tbl2c_PartneoClientAcc 
    ON tbl2b_PartneoSeg.PAID = tbl2c_PartneoClientAcc.PAID) 
    ON tbl2a_PPNCharacteristics.PAID_PFC_PSFC = tbl2b_PartneoSeg.PAID_PFC_PSFC) 
    ON tbl1_PartPricingDataAggregation.PPN = tbl2a_PPNCharacteristics.PPN) 
    LEFT JOIN tbl3_HierarchySeg 
    ON tbl2b_PartneoSeg.L2_L3 = tbl3_HierarchySeg.L2_L3;

  5. #20
    hapm is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    197
    How do you apply the other filters in your form? using DoCmd.OpenReport? I can't find a reference to the other form fields in your query, so it looks like you're not filtering anything at all.

  6. #21
    Ace2014 is offline Advanced Beginner
    Windows XP Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    88
    Oh wow.

    I didn't realize the form was supposed to be linked to a query.
    That's what I was doing in the beginning, but then someone showed me this way and I just figured it did the same thing.
    Although that would make sense, since eventually, I'd want to create a table and export it into excel and then clear all traces of the process.

    So the query I just showed above, that is where all the data with segmentations is what I want the users to have access to.

    I'm trying to make an interface that allows the users to narrow the scope of the data they have access to and to then export it into excel.

    Originally I had a process that alllowed users to input values into a table from a form and then a query would run to reduce the data scope with each added criteria.

    Ex:
    FormL1 - select L1
    Upon pressing F9, table.L1 would be updated
    Premade queryL1 linking table.L1 to accumulationQuery.L1 would run, reducing data scope
    It would open FormL2
    User selects L2
    Upon pressing F9, table.L2 would be updated
    Premade queryL2 linking tableL2 to queryL1.L2 would run, reducing data scope
    It would open FormL3
    Repeat process
    For Level 4, I have dates and need to ask for either all dates (if isNull, return all, if not allDates>inputDate)
    Level 5, I need the users to be able to select none, or one, or multiple brands based off previous queries (for some reason multiple rows couldn't be added)
    Level 6, I need the users to be able to select none, one, or multiple available markets based off previous queries

    Did that make sense?
    Is there any easier way to do that?

    I mean, I don't know if I need all the tables, I could create a query with a where statement saying where isNull"Form""FormName""Formname.ColumnHeading" (return all values) false("Form""FormName""Formname.ColumnHeading"=cor responding ColumnHeading in the query/table.
    But then I'd need to be able to select the query for the next criteria.

  7. #22
    hapm is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    197
    You can make a query that filters all criterias at the same time extending the filter I gave you. No need to update a table or create multible queries. You can cascade multiple queries of course, if you prefere this for the sake of overview. I mostly try to reduce the number of queries to a minimum, and don't have queries for interim results, but thats only a preference of mine and not a must have imho.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 03-15-2013, 04:00 AM
  2. Subtracting Dates in Queries
    By seanpbent in forum Access
    Replies: 1
    Last Post: 02-01-2013, 04:28 PM
  3. Dates and Queries (its hard to describe!)
    By Lauren1989 in forum Queries
    Replies: 6
    Last Post: 03-31-2011, 01:45 PM
  4. Replies: 4
    Last Post: 04-01-2009, 08:49 PM
  5. Handling dates in queries
    By mrk68 in forum Access
    Replies: 4
    Last Post: 03-23-2009, 06:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums