Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2010
    Location
    UK
    Posts
    160

    Unanswered: Run query which looks at text box for filtering

    H all,

    I have a form call Main. In main is an unbound text box called cbo_ContractSelection in the form header.


    In the embedded query which drives the form "Main" i have the following code in the criteria field....

    Like [forms]![Main]![cbo_ContractSelection].[Text] & "*" Or Is Null

    The idea is that as i type in the text field cbo_ContractSelection it filters the record in the form. On the Keyup event i just requery form Main but none of the records seem to get filtered.

    What i did notice is this code does work if the text box cbo_ContractSelection is driving a subform rather than the form it resides in.

    hope thats clear?
    thanks for any help
    Marcus

  2. #2
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    495
    Provided Answers: 24
    Usu. combo boxes are called cbo_
    but dont use the .TEXT.
    Just use
    [forms]![Main]![cbo_ContractSelection]
    and you use the AFTERUPDATE event to filter.

    The afterupdate should just me.requery to read the new filter.

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    another way of doing the same thing is to sset a filter when the users selects an item in the list/combo box. you probably also want to have a command button that removes the filter

    a reason for using thsi approach is that it doesnt' directly affect a query. I ifnd it easier to understand what is going on if I can see the effect of UI objects withint code than queries which are elsewhere. it also means that queries are decoupled form forms or reports, meaning those queries can be used in more than one palce
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    Sep 2010
    Location
    UK
    Posts
    160
    thanks for your help, went with a command button to remove the filter too which works great.
    thanks again
    marcus

Posting Permissions

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