Results 1 to 6 of 6
  1. #1
    kafedral is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Apr 2011
    Posts
    3

    Basic question about fitering


    Hi, I need to make a button that will allow me to filter the data in my forms. I tried using the magic wizard but all it did was filter the data one time and then it just uses the last value assigned to it, same thing happens when i use macros or basic vb code using Me.Filter() function.
    I'm hoping someone can help me out.

  2. #2
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    What code do you have? Will you post it?

  3. #3
    kafedral is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Apr 2011
    Posts
    3
    well just like i told u i used a very basic VB code and it does what the macro/wizard create button does:
    Me.Filter = "Country = filter_p"
    Me.FilterOn = True

    just in case i wasn't clear before, i want to make a button that will let me enter a new search parameter if i want to ether that or somehow create a drop down menu like the one that shows when ever you click the filter button on under the Home tab.
    Thanks for your help.

  4. #4
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Me.Filter = "Country = filter_p"
    Me.FilterOn = True
    This is why I asked about the code you have. If "filter_P" is the parameter, then you have to concantate it to the filter string. If "filter_P" is a string, then try:

    Code:
    Me.Filter = "[Country] = '" & filter_p & "'"
    Me.FilterOn = True
    Expanded, it looks like" Me.Filter = "[Country] = ' " & filter_p & " ' " . (The single quotes are text delimiters - there should not be any spaces.)

  5. #5
    kafedral is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Apr 2011
    Posts
    3
    Ok I'm confused, it did work like this:
    Code:
    Private Sub Command22_Click()
    Me.Filter = "OrderID = '" & filter_p & "'"
    Me.FilterOn = True
    End Sub
    it says "Data type mismatch" ( and i tried to define filter_p with Dim as String)
    but it did work like this:
    Code:
    Private Sub Command22_Click()
    Me.Filter = "OrderID = filter_p"
    Me.FilterOn = True
    End Sub
    with one problem, it lets me filter it only one time, to do it again i need to reopen the form
    so if you can help me out I'll be very grateful.

  6. #6
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    What is the field type of "OrderID"?? (text or number)
    If it is text, then it needs delimiters. If it is a number, then it doesn't need a delimiter. So it would look like:

    Code:
    Private Sub Command22_Click()
    Me.Filter = "OrderID = " & filter_p
    Me.FilterOn = True
    End Sub

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

Similar Threads

  1. Basic Question
    By za20001 in forum Queries
    Replies: 2
    Last Post: 04-11-2011, 03:59 PM
  2. basic (sorry) question
    By wokeeffe in forum Database Design
    Replies: 1
    Last Post: 12-21-2010, 11:20 AM
  3. Basic Question
    By Dalagrath in forum Forms
    Replies: 12
    Last Post: 10-31-2010, 05:36 AM
  4. Really basic question
    By jimlaw in forum Forms
    Replies: 1
    Last Post: 07-27-2009, 07:20 AM
  5. Basic Question
    By chris11590 in forum Forms
    Replies: 0
    Last Post: 08-04-2008, 05:57 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