Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2010
    Posts
    39

    Unanswered: vba code no longer working

    hi guys, i was tweaking my code earlier to place in some warning boxes, as somehow, its stopped the search function. I can no longer search either by date (neither between or singular) or client and its no longer filtering the data.

    Help?

    Code:
    Private Sub SEARCH_Click()
    
    DoCmd.SetWarnings False
    
    Dim strWhere As String
    
    
    If Not IsNull(Me.CMDCLIENT) Then
    strWhere = strWhere & "[CLIENT] Like '*" & CMDCLIENT & "*'"
    End If
    
    If strWhere = "" Then
    MsgBox "ENTER INFORMATION", vbInformation, "Nothing to do."
    Else
    With Me
    .Filter = strWhere
    .FilterOn = True
    End With
    End If
    
    
    Dim sWhere As String
    
    If Not IsNull(Me.txtstartdate) Then
    sWhere = "ENTERDAT >= #" & Format(CDate(Me.txtstartdate), "mm/dd/yyyy") & _
           " 00:00# AND ENTERDAT <= #" & Format(CDate(Me.txtenddate), "mm/dd/yyyy") & " 23:59#"
    End If
    
    
    With Me
    .Filter = sWhere
    .FilterOn = True
    End With
    
    
       
    End Sub

  2. #2
    Join Date
    Oct 2009
    Posts
    340
    deactive lines with a ' to strip it down to basics...and then test as you go....that's the only way to trouble shoot....

  3. #3
    Join Date
    May 2010
    Posts
    601
    Quote Originally Posted by colenzo View Post
    hi guys, i was tweaking my code earlier to place in some warning boxes, as somehow, its stopped the search function. I can no longer search either by date (neither between or singular) or client and its no longer filtering the data.

    Help?

    Code:
    Private Sub SEARCH_Click()
    
    DoCmd.SetWarnings False
    
    Dim strWhere As String
    
    
    If Not IsNull(Me.CMDCLIENT) Then
    strWhere = strWhere & "[CLIENT] Like '*" & CMDCLIENT & "*'"
    End If
    
    If strWhere = "" Then
    MsgBox "ENTER INFORMATION", vbInformation, "Nothing to do."
    Else
    With Me
    .Filter = strWhere
    .FilterOn = True
    End With
    End If
    
    
    Dim sWhere As String
    
    If Not IsNull(Me.txtstartdate) Then
    sWhere = "ENTERDAT >= #" & Format(CDate(Me.txtstartdate), "mm/dd/yyyy") & _
           " 00:00# AND ENTERDAT <= #" & Format(CDate(Me.txtenddate), "mm/dd/yyyy") & " 23:59#"
    End If
    
    
    With Me
    .Filter = sWhere
    .FilterOn = True
    End With
    
    
       
    End Sub

    Try adding the line:

    Exit Sub after the message box line


    Example:

    Code:
    If strWhere = "" Then
       MsgBox "ENTER INFORMATION", vbInformation, "Nothing to do."
    
      Exit Sub
    
    Else
    Boyd Trimmell aka HiTechCoach HiTechCoach.com (free access stuff)
    Microsoft MVP - Access Expert
    BPM/Accounting Systems/Inventory Control/CRM
    Programming: Nine different ways to do it right, a thousand ways to do it wrong.
    Binary--it's as easy as 1-10-11

  4. #4
    Join Date
    Jan 2010
    Posts
    39
    [/QUOTE]
    Code:
    If strWhere = "" Then
       MsgBox "ENTER INFORMATION", vbInformation, "Nothing to do."
    
      Exit Sub
    
    Else
    [/QUOTE]

    Tried this.. no effect. Still will not search for a darn well thing! This darn thing was working this morning. Argh, this search form is going to kill me yet!

  5. #5
    Join Date
    May 2010
    Posts
    601
    Quote Originally Posted by colenzo View Post
    Code:
    If strWhere = "" Then
       MsgBox "ENTER INFORMATION", vbInformation, "Nothing to do."
    
      Exit Sub
    
    Else
    Tried this.. no effect. Still will not search for a darn well thing! This darn thing was working this morning. Argh, this search form is going to kill me yet![/QUOTE]

    I would suggest two things:

    1) manually compile the VBA code to look for errors
    2) run a compact

    Hopefully you are making regular backups as you develop. If it were me, I would look at the backup of the database to see if you can find a working versions.
    Boyd Trimmell aka HiTechCoach HiTechCoach.com (free access stuff)
    Microsoft MVP - Access Expert
    BPM/Accounting Systems/Inventory Control/CRM
    Programming: Nine different ways to do it right, a thousand ways to do it wrong.
    Binary--it's as easy as 1-10-11

  6. #6
    Join Date
    Jan 2010
    Posts
    39
    Oh yes, backed up frequently. Luckily, there's no data in it at the moment, its purely in the design stage with only testing data running in it.

    I've pulled out the Search form and replaced the entire thing. Now the Client search works, however the date search still is forming a problem.

    Does anyone have any good links for setting up a date search function as i'm thinking of replacing the entire code in that section and would like to read up on it a little more.

    Thanks for all the help so far! Appriciated!

  7. #7
    Join Date
    Oct 2004
    Location
    Melbourne, Australia
    Posts
    201
    Shouldn't there be a Me.Requery to activate the filter after setting it up ?

Posting Permissions

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