Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20
  1. #16
    Keefay78 is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    May 2019
    Posts
    36
    Yeh, it seems like the more you start to learn the more you realise there is SO much more you need to know.
    I had a go at your suggestions, incorporating wha you said into the code.

    I tried to add:

    Public Const conJetDate As String = "\#mm\/dd\/yyyy\#" just under the Private Sub for the button, it did not like the Public statement, I removed that, I got no errors but the butto doesnt really do anything.

    I think I might scrap the boxes and the buttons and start again, I may be so far down the rabbit hole at this point LOL, I mean bst part of 7 hours of compile errors eesh



    Its a shame, I mean independently the buttons worked fine butjoining them was my undoing

  2. #17
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Well, that suggestion was based on this "Actually I'd have it in a standard module". That's where it would need to be to be declared like I did. Does this work?

    Code:
      Const conJetDate = "\#mm\/dd\/yyyy\#"
        
      If Not IsNull(Me.cboSurgeonSearch) Then
        strWhere = strWhere & "([Surgeon] = '" & Me.cboSurgeonSearch & "') AND "
      End If
    
      If Not IsNull(Me.cboProcSearch) Then
        strWhere = strWhere & "([procedure] = '" & Me.cboProcSearch & "') AND "
      End If
    
      If Not IsNull(Me.txtEndDate) Then
        strWhere = strWhere & "([OpDate] < " & Format(CDate(Me.txtEndDate) + 1, conJetDate) & ") AND "
      End If
        
      If Not IsNull(Me.txtStartDate) Then
        strWhere = strWhere & "([OpDate] >= " & Format(Me.txtStartDate, conJetDate) & ") AND "
      End If
        
      lngLen = Len(strWhere) - 5
      If lngLen <= 0 Then
        MsgBox "No criteria", vbInformation, "Nothing to do."
      Else
        strWhere = Left$(strWhere, lngLen)
        Me.Filter = strWhere
        Me.FilterOn = True
        Me.Refresh
      End If
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #18
    Keefay78 is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    May 2019
    Posts
    36
    That actually worked like a dream, I am delighted!!

    Same time like maaaan I still don't even see how its so different lol

    I have to input date in US format mm/dd, if I change that round in the constant will that allowe me to enter it in dd/mm ?

  4. #19
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Your code had the filtering bit inside the test for one of the dates, so it only ran if that date textbox was populated. That's why the button didn't appear to be doing anything. Among other issues.

    I don't have much experience with other date formats. If you apply a date format like Short Date to those 2 textboxes does it work? My system is set to US date format, so I can't really test.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #20
    Keefay78 is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    May 2019
    Posts
    36
    Yeah changing the date format in the ConJet sorted that.

    I appreciate that this database is rough around the edges, I hope to use it as a stepping stone going forward to improving my MSAccess skills though

    The hlp from you guys on here is gold dust though it really is

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

Similar Threads

  1. Form not filtering dates correctly
    By whisp0214 in forum Forms
    Replies: 5
    Last Post: 04-24-2018, 01:28 PM
  2. Replies: 8
    Last Post: 02-19-2016, 10:59 AM
  3. Working & Filtering Dates
    By the_reg in forum Access
    Replies: 2
    Last Post: 07-26-2013, 07:35 AM
  4. Filtering based on form dates
    By cbh35711 in forum Programming
    Replies: 3
    Last Post: 03-13-2012, 11:46 AM
  5. Filtering Dates Error!
    By emilyrogers in forum Forms
    Replies: 3
    Last Post: 02-15-2011, 03:00 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