Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2012
    Location
    New Zealand
    Posts
    10

    Unanswered: DateAdd VBA Syntax

    Private Sub btnExpCerts_Click()
    Dim strReport As String
    Dim strDateField As String
    Dim lngView As Long

    strReport = "rptEmplExpCerts"
    lngView = acViewPreview

    'filter
    strWhere = "[tblCerts]![CertDateExp]<DateAdd(""m"",3,Date())", ""

    DoCmd.OpenReport strReport, lngView, , strWhere

    End Sub

    I want to open the report where any [CertDateExp] is within 3 months but I'm getting bleary eyed
    please help

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    strWhere = "[tblCerts]![CertDateExp] < " & DateAdd("m",3,Date())
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Feb 2012
    Location
    New Zealand
    Posts
    10
    Ok Ive got past the syntax problem but my report opens Blank
    the Filter reads
    [CertDateExp] < 21/04/2013 if I change that to [CertDateExp] < #21/04/2013#

    I get the results
    so how or where in my code do I get the date to format correctly

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    strWhere = "[tblCerts]![CertDateExp] < #" & DateAdd("m",3,Date()) & "#"
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Feb 2012
    Location
    New Zealand
    Posts
    10
    Solved thanks for your help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •