Results 1 to 7 of 7
  1. #1
    Robyn_P's Avatar
    Robyn_P is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Nov 2017
    Posts
    150

    Requery only works in debug mode

    Hey all,Okay I'm stumped.I have a form and with a combo box on that contains a long list of items, I have a text box which filters the list of items as you type. In the On Change event I have me.cboItem.requery. This works absolutely fine if I set a breakpoint and then run the code, it does not work when there is no break point. I have another combo box in the form which also has the Me.cboItem.requery code in it and this works absolutely fine, picking up the criteria from both it and then text box when it's after_update event is triggered. Why oh who of why does the requery on the text box not work when the code is just allowed to run, it definitely executes just has no effect.

  2. #2
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    I have a text box which filters the list of items as you type.
    Combo boxes already do this on the main bound field, why the extra text box and code?

  3. #3
    Robyn_P's Avatar
    Robyn_P is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Nov 2017
    Posts
    150
    The text box is so I can filter the list of items in the combobox because it's very long and a faff to find the one you want through scrolling through the list.The query of the combo box has the criteria LIKE "*" & [Forms]![formName]![txtFilter] & "*" It works perfectly when requeryied slowly in debug mode or after I update the other combo box and execute the requery code underlying that. I have almost exactly the same set up on another form and it works with no problems.

  4. #4
    Robyn_P's Avatar
    Robyn_P is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Nov 2017
    Posts
    150
    Oh I see what you mean, this is a multi column combo box, the data I'm filtering on is in the third column displayed in the cobo box for information only (it's an item part number)

  5. #5
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    It does work. I use it all the time.
    Are you sure you are using the correct combo name?
    Do you have the correct query attached, one that references combo1?

    Code:
    sub cboState_Afterupdate()
    cboCity.requery
    end sub
    where the query =
    select [city] from tData where [state]=forms!myForm!cboState

  6. #6
    Robyn_P's Avatar
    Robyn_P is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Nov 2017
    Posts
    150
    Got it. The value of txtFilter isn't updated until you click out of the box (after update). If you want to be doing a filter as you type, I need to reference txtFilter.text in the onchange event which does. I think this is therefore relatively easy to solve, I just need to code building the filter. Does that make sense?

  7. #7
    Robyn_P's Avatar
    Robyn_P is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Nov 2017
    Posts
    150
    In case anyone is wondering, I solved this by creating a hidden text box called txtHidden that I populate with txtFilter.text such that the underlying code in the on_change event is just:Me.txtHidden = me.txtFilter.text; me.cboItem.requery. The underlying query of the combo box now referenced txtHidden.Works perfectly, Thanks

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

Similar Threads

  1. Replies: 7
    Last Post: 10-02-2016, 05:21 AM
  2. Replies: 8
    Last Post: 06-26-2015, 06:00 PM
  3. Code runs in break/debug mode but not in normal mode
    By hansendl in forum Programming
    Replies: 2
    Last Post: 10-15-2014, 07:23 AM
  4. Replies: 4
    Last Post: 11-26-2013, 10:47 AM
  5. Replies: 5
    Last Post: 08-29-2011, 04:06 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