Results 1 to 9 of 9
  1. #1
    Batraul is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2014
    Posts
    7

    Write the criteria of a query in the event code


    Hi all!

    Is it possible to write the criteria in a textbox and, depending if the first character is "<", ">", "=", etc, write a code in the event of this textbox which fills the criteria of that query through a variable or something like that?
    Off course, to check if the first character is >< I would use function MID.


    Thank you!

  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,931
    AFAIK, operators (<,>,=, LIKE) in query criteria cannot be dynamic.

    I don't use dynamic parameterized queries. I use code that applies filter to form or report. Review: http://www.allenbrowne.com/ser-62code.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.

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    It might be better for you and readers if you could tell us in plain English WHAT you are trying to accomplish. There may be options, but knowing WHAT is key.

  4. #4
    Batraul is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2014
    Posts
    7
    Ok. Sorry if I haven't explained well.
    I wanted to upload the file but I've seen that it's only possible to upload images and videos. So, here you have my form:

    Click image for larger version. 

Name:	Captura.JPG 
Views:	11 
Size:	64.2 KB 
ID:	19128
    There're some textboxes and a listbox which source is a query. In the criterias of the query I write Like [Forms]![Formulario1]![Textbox] & "*". That creates a filter while you type in the textboxes.
    For example, if I type an "H" on the Reference textbox and "6" on the ØD textbox, the listbox will show all the registers that the reference starts by "H" and the ØD is 6. Like in the following screenshot:
    Click image for larger version. 

Name:	Captura2.JPG 
Views:	11 
Size:	55.3 KB 
ID:	19129
    But sometimes I need the listbox to show all the registers that ØD is "greater than" 6, and that's what I don't know how to do.

  5. #5
    Batraul is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2014
    Posts
    7

    Attachment

    Quickfinder.zip

    I think now I could attach the file...

  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,931
    What do you think of the suggestion in post 2?
    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
    Batraul is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2014
    Posts
    7
    Quote Originally Posted by June7 View Post
    What do you think of the suggestion in post 2?
    But I have a query from a table with almost 4000 registers? And that's only the begining, it will be more than double.
    I'm sorry but I'm new to vba Access. Is it really viable to do for this case?

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    What is a register - a record? Even double 4000 is a very small dataset.

    Is what viable - the code from the referenced link? Yes.
    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.

  9. #9
    Batraul is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2014
    Posts
    7
    Quote Originally Posted by June7 View Post
    What is a register - a record? Even double 4000 is a very small dataset.

    Is what viable - the code from the referenced link? Yes.
    Ok June7. I will try to understand properly the code and I will try to create.
    Thank you very much for the help.

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

Similar Threads

  1. Replies: 1
    Last Post: 06-09-2014, 11:17 AM
  2. How to write SQL code in VBA
    By stildawn in forum Modules
    Replies: 3
    Last Post: 05-12-2014, 07:56 AM
  3. Replies: 2
    Last Post: 09-04-2013, 11:01 PM
  4. Replies: 7
    Last Post: 05-28-2013, 09:11 AM
  5. How To Write Vb Code For This?
    By townguy in forum Queries
    Replies: 1
    Last Post: 09-15-2011, 12:00 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