Results 1 to 7 of 7
  1. #1
    MichaelA is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Sep 2019
    Location
    Wisconsin
    Posts
    139

    Help with Split Form Query Where There Are No Results

    I have a split form with a Combo Box on top to filter Book Titles and Authors. It works great unless I type a something that yields no results. As soon as I type a string where there is no author or title matching, I get a run-time error '2105' You can't go to the specific record. The whole form except the Form header disappears. I can end or go to debug. Could someone help me prevent that. I've included the code below.

    Thank you!


    Code:
    Option Compare Database
    Option Explicit
    Private blnSpace As Boolean
    
    
    
    
    Private Sub cboFilter_Change()
        If blnSpace = False Then
            Me.Requery
            Refresh
            cboFilter.SetFocus
            cboFilter.SelStart = Len(Me.cboFilter.Text)
        End If
    End Sub
    
    
    Private Sub cboFilter_KeyPress(KeyAscii As Integer)
        If KeyAscii = 32 Then
            blnSpace = True
        Else
            blnSpace = False
        End If
    End Sub
    
    
    Private Sub Form_Open(Cancel As Integer)
        Me.cboFilter.SetFocus
    End Sub


  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    In the top of CHANGE event, try putting
    Docmd.SetWarnings False

    Then at the end of the sub, turn it back on.
    This may prevent the msg, but split forms are strange animals.

  3. #3
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    I would not use the change event as it triggers for every key stroke, move the code to the AfterUpdate event of the combo and see what happens (and you don't need all that code, just have a Me.Requery).

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  4. #4
    MichaelA is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Sep 2019
    Location
    Wisconsin
    Posts
    139
    Ranman256

    I tried this. I still get the same result.

    Thank you!

  5. #5
    MichaelA is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Sep 2019
    Location
    Wisconsin
    Posts
    139
    Quote Originally Posted by Gicu View Post
    I would not use the change event as it triggers for every key stroke, move the code to the AfterUpdate event of the combo and see what happens (and you don't need all that code, just have a Me.Requery).

    Cheers,
    I moved it to the AfterUpdate event and it works but it doesn't filter the results as you type and it doesn't filter the results until after you tab away from the combo box. Is there a way around this? The idea for the filter was to get real time results in case you don't know the exact title of the book or the exact spelling of the authors name. If it filters out, letter by letter as you type, it narrows the number of records with each letter. Oftentimes, resulting in finding what you are looking for before you ever type a whole word.

    Thank you!

  6. #6
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    Isn't that what autocomplete does for the combo list?
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  7. #7
    MichaelA is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Sep 2019
    Location
    Wisconsin
    Posts
    139
    Quote Originally Posted by Gicu View Post
    Isn't that what autocomplete does for the combo list?
    As it is, it is not filtering the combobox but three different fields in the datasheet below.

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

Similar Threads

  1. Replies: 1
    Last Post: 09-18-2017, 06:49 PM
  2. search form results into split form
    By murphy63 in forum Forms
    Replies: 4
    Last Post: 11-23-2016, 08:32 AM
  3. query results into split form?
    By murphy63 in forum Forms
    Replies: 10
    Last Post: 10-04-2016, 09:53 AM
  4. Replies: 1
    Last Post: 04-09-2015, 05:13 PM
  5. Replies: 6
    Last Post: 05-14-2012, 07:24 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