Results 1 to 7 of 7
  1. #1
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328

    Enter a space in text box used for filter source

    I am using A2007 and A2003. I have a continuous form that is used for what my user calls his "quick search". The user types in a character sequence in a text box on the form header. As he types, the list of items (4 columns) on the form narrows down to match the box's character sequence. The purpose is to identify details about a customer who calls in without having to ask the customer questions and without asking for spelling help.



    I use the following code, typical for several other boxes on the form
    Private Sub BTbox_Change()
    Me.FilterOn = True
    Dim BT As String
    BT = Me.BTbox.Text
    Filter = "[BoatType] Like ""*" & BT & "*"" "
    SendKeys "{f2}" ‘(To keep BTbox in navigation mode)
    End Sub

    The problem is that if, BTbox is a text box, the user can’t enter spaces. If he types in “Newport 30” it shows and filters for “Newport30”. If I make BTbox a Combo Box (I would rather not), spaces can be entered fine. From what I find by googling, hiding the combo box down arrow after selection is not possible. Is it possible to modify something so that he can enter a space in the text box? Or-is there some way to hide the down arrow after the box is selected?

    Any help much appreciated.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Not understanding why the textbox is rejecting spaces. Never seen that happen. Do you know what is causing this limitation?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328
    Quote Originally Posted by June7 View Post
    Not understanding why the textbox is rejecting spaces. Never seen that happen. Do you know what is causing this limitation?
    I tried the following:
    1-remove the filter command only. Result: I can put spaces, but the text box stays in edit mode, even though sending F2
    2-remove the sendKeys{F2} only. Result: Cannot enter a space, text box stays in edit mode.

    So, something about filter command is doing it to a text box, but not a combo box.

    Also, something for me that is weird. When I step through the code with F8, the sendKeys{F2} opens up a screen related to the Library.

    I should have mentioned that even though I work with A2007, I do all things in mdb. Also, I checked on computer with A2003 and same result.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    At first I thought the issue might be because Access drops trailing spaces. So as the text is selected after each trigger of the Change event, the space would be dropped. However, I tested your code and cannot replicate the issue. When I type first character in textbox, the SendKeys code opens zoom box with that first character selected. I have to retype the character and continue typing. After pressing OK, whatever I typed is populated into textbox, including spaces. The filter text includes spaces.

    Not really sure what you mean by 'navigation' and 'edit' modes.

    Interesting, when I manually press F2, it toggles selection/unselection of text in textbox. More interesting, when I use DoCmd.RunCommand acCmdZoomBox instead of SendKeys I end up in an endless loop. You might try OnEnter event with DoCmd instead of Change and SendKeys.

    Cannot replicate the issue. If you want to provide db for analysis, follow instructions at bottom of my post.

    I've never used Change event. I use combobox with AutoExpand and AfterUpdate event to apply filter.

    Don't understand your issue with combobox. After selecting item from list, the drop list closes.
    Last edited by June7; 06-22-2013 at 12:39 PM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328
    I am attaching a file, cut down to essentials of what I am doing.

    I use OnChange rather than afterUpdate because I (my user) want the lists to narrow down for each character entry. Without going into details, this is what user wants and needs. The issue is that, with a text box, spaces are not allowed, and I need them. I can use a combo box, but it may confuse some of the users. Unfortunately, there is no way to disguise a combo box as a text box once it has been selected. Thanks for for quick action.

    Quote Originally Posted by June7 View Post
    At first I thought the issue might be because Access drops trailing spaces. So as the text is selected after each trigger of the Change event, the space would be dropped. However, I tested your code and cannot replicate the issue. When I type first character in textbox, the SendKeys code opens zoom box with that first character selected. I have to retype the character and continue typing. After pressing OK, whatever I typed is populated into textbox, including spaces. The filter text includes spaces.

    Not really sure what you mean by 'navigation' and 'edit' modes.

    Interesting, when I manually press F2, it toggles selection/unselection of text in textbox. More interesting, when I use DoCmd.RunCommand acCmdZoomBox instead of SendKeys I end up in an endless loop. You might try OnEnter event with DoCmd instead of Change and SendKeys.

    Cannot replicate the issue. If you want to provide db for analysis, follow instructions at bottom of my post.

    I've never used Change event. I use combobox with AutoExpand and AfterUpdate event to apply filter.

    Don't understand your issue with combobox. After selecting item from list, the drop list closes.
    Attached Files Attached Files

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Not understanding where your code goes wrong. There are many examples of this technique that do allow spaces. Here is one I tested http://www.opengatesw.net/ms-access-...pe-Access.html and another example http://www.allenbrowne.com/AppFindAsUType.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328
    Thanks much-I tried the first one and works fine. I don't understand all he code, but will pour through it and try to understand where mine goes wrong. Maybe something to do with the key press event that recognizes the space bar key code?

    I will look at Browne's also. Thanks again-I really appreciate the effort that you put into this. I will mark as SOLVED!


    Quote Originally Posted by June7 View Post
    Not understanding where your code goes wrong. There are many examples of this technique that do allow spaces. Here is one I tested http://www.opengatesw.net/ms-access-...pe-Access.html and another example http://www.allenbrowne.com/AppFindAsUType.html

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

Similar Threads

  1. Eliminate Space from Hidden Text Box using CanShrink
    By Casey Sanders in forum Reports
    Replies: 4
    Last Post: 01-29-2013, 06:03 PM
  2. Replies: 3
    Last Post: 01-03-2013, 04:32 PM
  3. Replies: 7
    Last Post: 10-28-2012, 02:55 PM
  4. Replies: 2
    Last Post: 03-01-2012, 12:21 PM
  5. Space between two text boxes
    By ashbear in forum Reports
    Replies: 3
    Last Post: 08-17-2011, 05:02 PM

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