Results 1 to 5 of 5
  1. #1
    aus_son is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2020
    Posts
    2

    Microsoft Access: Vulnerabilities Database - Query Past 6 Months

    I need to make a query that will show the past 6 months for each month. So now for an example, if it was February I need to create a SLA report for February, but I need to generate trend graph for the past 6 months to include in the report. But it just continues to show months that are not for the past 6 months.

    SQL VIEW


    HTML Code:
    <code>
    SELECT Vulnerabilities.[Host IP], Vulnerabilities.CVSS, Vulnerabilities.[Risk Level], Vulnerabilities.Vulnerability, Vulnerabilities.[Scan Date]FROM VulnerabilitiesWHERE (((Vulnerabilities.[Risk Level])="Serious" Or (Vulnerabilities.[Risk Level])="High" Or (Vulnerabilities.[Risk Level])="Medium") AND ((Vulnerabilities.[Scan Date]) Between #8/1/2020# And #1/31/2020#));
    </code>
    DESIGN VIEW
    Click image for larger version. 

Name:	Screen Shot 2020-05-01 at 2.42.43 PM.png 
Views:	9 
Size:	60.6 KB 
ID:	41717

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    on a form put in 3 text boxes: txtToday, txtStartDate, txtEndDate
    set the default txtToday = Date()
    when the form opens, set the other 2 boxes:

    Code:
    sub Form_Load()
    vStart = month(txtToday ) & "/1/" & year(txtToday )
    
    'get end of the month
    txtEndDate = dateAdd("d",-1,dateAdd("m",1,vStart))
    txtStartDate = DateAdd("m",-6,vStart)
    
    end sub
    


    the query then uses the textboxes for the criteria:
    select * from table where [dateFld] between forms!fMyForm!txtStartDate and forms!fMyForm!txtEndDate

  3. #3
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    The first thing I would do is remove ALL spaces in object names.

    In the where clause, you have
    Code:
    Vulnerabilities.[Scan Date] Between #8/1/2020# And #1/31/2020#
    Shouldn't it be
    Code:
    Vulnerabilities.[Scan Date] Between #8/1/2019# And #1/31/2020#

    And instead of hard coding the dates in the query, I would have a form with two text controls for the Start Date and the End Date.......much easier to change the dates for the query.

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933

  5. #5
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    removed cross posting message
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. How to calculate # of months past a date?
    By djclinton15 in forum Queries
    Replies: 8
    Last Post: 02-05-2017, 03:48 PM
  2. Replies: 13
    Last Post: 09-12-2016, 09:13 AM
  3. [HELP] Microsoft Access Database 2007
    By jonas767 in forum Access
    Replies: 4
    Last Post: 06-12-2015, 11:21 PM
  4. Microsoft Access for database
    By liyana husni in forum Access
    Replies: 1
    Last Post: 02-15-2015, 09:46 PM
  5. Replies: 6
    Last Post: 11-25-2013, 10:53 AM

Tags for this Thread

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