Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Press button to filter or query a form

Discussion in 'Information Technology' started by Levans digital, Jul 28, 2006.

  1. Levans digital

    Levans digital
    Expand Collapse
    Guest

    Help Please?

    Status:
    I have a table called "Locationtbl" in that table their is a field "location"
    I enter Test like A1, A2, C2, etc.. which are shelf # in an actual storeroom.
    For example 1 box Pens will be stored in Shelf "A2"

    On a form based on the table can I press lets say a toggle or command button
    to query or filter for only the items on a specific shelf?

    Lets say I have a button called "Shelf A2" and when I press it only the
    items that has been placed on Shelf "A2" be returned.

    On my form I already have all the buttons I have "A1" A2 A3 A4 and B1, B2 B3
    B4 and C1 C2 C3 C4.

    Help
     
  2. Loading...


  3. schasteen

    schasteen
    Expand Collapse
    Guest

    On the click event of your button
    Me.Filter = "[location] = 'A2'"
    Me.FilterOn = True

    It would be easier to have a combo box that has the locations that the user
    selects and the filter

    Me.Filter = "[location] = '" & Me![ComboBox] & "'"
    Me.FilterOn = True

    Then a button to remove the filter
    Me.FilterOn = False


    "Levans digital" wrote:

    > Help Please?
    >
    > Status:
    > I have a table called "Locationtbl" in that table their is a field "location"
    > I enter Test like A1, A2, C2, etc.. which are shelf # in an actual storeroom.
    > For example 1 box Pens will be stored in Shelf "A2"
    >
    > On a form based on the table can I press lets say a toggle or command button
    > to query or filter for only the items on a specific shelf?
    >
    > Lets say I have a button called "Shelf A2" and when I press it only the
    > items that has been placed on Shelf "A2" be returned.
    >
    > On my form I already have all the buttons I have "A1" A2 A3 A4 and B1, B2 B3
    > B4 and C1 C2 C3 C4.
    >
    > Help
     
  4. Levans digital

    Levans digital
    Expand Collapse
    Guest

    Hello Chasteen,

    Thanks very much.
    It works great I went ahead and use the combo as you mentioned. One more
    question How can I print the filtered form to a report must I put VBA in the
    report of simply base it on locationstbl?

    "schasteen" wrote:

    > On the click event of your button
    > Me.Filter = "[location] = 'A2'"
    > Me.FilterOn = True
    >
    > It would be easier to have a combo box that has the locations that the user
    > selects and the filter
    >
    > Me.Filter = "[location] = '" & Me![ComboBox] & "'"
    > Me.FilterOn = True
    >
    > Then a button to remove the filter
    > Me.FilterOn = False
    >
    >
    > "Levans digital" wrote:
    >
    > > Help Please?
    > >
    > > Status:
    > > I have a table called "Locationtbl" in that table their is a field "location"
    > > I enter Test like A1, A2, C2, etc.. which are shelf # in an actual storeroom.
    > > For example 1 box Pens will be stored in Shelf "A2"
    > >
    > > On a form based on the table can I press lets say a toggle or command button
    > > to query or filter for only the items on a specific shelf?
    > >
    > > Lets say I have a button called "Shelf A2" and when I press it only the
    > > items that has been placed on Shelf "A2" be returned.
    > >
    > > On my form I already have all the buttons I have "A1" A2 A3 A4 and B1, B2 B3
    > > B4 and C1 C2 C3 C4.
    > >
    > > Help
     
  5. schasteen

    schasteen
    Expand Collapse
    Guest

    DoCmd.OpenReport "reportName", acViewNormal, , "[location] ='" &
    Me![ComboBox] & "'"

    "Levans digital" wrote:

    > Hello Chasteen,
    >
    > Thanks very much.
    > It works great I went ahead and use the combo as you mentioned. One more
    > question How can I print the filtered form to a report must I put VBA in the
    > report of simply base it on locationstbl?
    >
    > "schasteen" wrote:
    >
    > > On the click event of your button
    > > Me.Filter = "[location] = 'A2'"
    > > Me.FilterOn = True
    > >
    > > It would be easier to have a combo box that has the locations that the user
    > > selects and the filter
    > >
    > > Me.Filter = "[location] = '" & Me![ComboBox] & "'"
    > > Me.FilterOn = True
    > >
    > > Then a button to remove the filter
    > > Me.FilterOn = False
    > >
    > >
    > > "Levans digital" wrote:
    > >
    > > > Help Please?
    > > >
    > > > Status:
    > > > I have a table called "Locationtbl" in that table their is a field "location"
    > > > I enter Test like A1, A2, C2, etc.. which are shelf # in an actual storeroom.
    > > > For example 1 box Pens will be stored in Shelf "A2"
    > > >
    > > > On a form based on the table can I press lets say a toggle or command button
    > > > to query or filter for only the items on a specific shelf?
    > > >
    > > > Lets say I have a button called "Shelf A2" and when I press it only the
    > > > items that has been placed on Shelf "A2" be returned.
    > > >
    > > > On my form I already have all the buttons I have "A1" A2 A3 A4 and B1, B2 B3
    > > > B4 and C1 C2 C3 C4.
    > > >
    > > > Help
     
  6. Levans digital

    Levans digital
    Expand Collapse
    Guest

    Hi Thanks it works.
    But I have one little problem lets say for the location I want All Items
    that are in the "C" column of the storage remember I have C! C2 C3 C4. In the
    combo I would type Like "C *"
    but it returns blank what do you think is the problem
    I used the button to remove the filter but when I hit print it prints blank
    rather than to print all locations.
    What do u think?

    "schasteen" wrote:

    > DoCmd.OpenReport "reportName", acViewNormal, , "[location] ='" &
    > Me![ComboBox] & "'"
    >
    > "Levans digital" wrote:
    >
    > > Hello Chasteen,
    > >
    > > Thanks very much.
    > > It works great I went ahead and use the combo as you mentioned. One more
    > > question How can I print the filtered form to a report must I put VBA in the
    > > report of simply base it on locationstbl?
    > >
    > > "schasteen" wrote:
    > >
    > > > On the click event of your button
    > > > Me.Filter = "[location] = 'A2'"
    > > > Me.FilterOn = True
    > > >
    > > > It would be easier to have a combo box that has the locations that the user
    > > > selects and the filter
    > > >
    > > > Me.Filter = "[location] = '" & Me![ComboBox] & "'"
    > > > Me.FilterOn = True
    > > >
    > > > Then a button to remove the filter
    > > > Me.FilterOn = False
    > > >
    > > >
    > > > "Levans digital" wrote:
    > > >
    > > > > Help Please?
    > > > >
    > > > > Status:
    > > > > I have a table called "Locationtbl" in that table their is a field "location"
    > > > > I enter Test like A1, A2, C2, etc.. which are shelf # in an actual storeroom.
    > > > > For example 1 box Pens will be stored in Shelf "A2"
    > > > >
    > > > > On a form based on the table can I press lets say a toggle or command button
    > > > > to query or filter for only the items on a specific shelf?
    > > > >
    > > > > Lets say I have a button called "Shelf A2" and when I press it only the
    > > > > items that has been placed on Shelf "A2" be returned.
    > > > >
    > > > > On my form I already have all the buttons I have "A1" A2 A3 A4 and B1, B2 B3
    > > > > B4 and C1 C2 C3 C4.
    > > > >
    > > > > Help
     
  7. schasteen

    schasteen
    Expand Collapse
    Guest

    For the print, you need an if then
    If isnull(me![ComboName]) then
    DoCmd.OpenReport "reportName", acViewNormal
    else
    DoCmd.OpenReport "reportName", acViewNormal, , "[location] ='" &
    Me![ComboBox] & "'"
    end if

    I am not fully sure on doing the other, try

    Me.Filter = "[location] like ' & Me![ComboName] & " *'"
    Me.FilterOn = True

    and just enter C in the combo box.

    This is untested, but you may need to redo the openreport
    DoCmd.OpenReport "reportName", acViewNormal, , "[location] like ' &
    Me![ComboName] & " *'"
    "Levans digital" wrote:

    > Hi Thanks it works.
    > But I have one little problem lets say for the location I want All Items
    > that are in the "C" column of the storage remember I have C! C2 C3 C4. In the
    > combo I would type Like "C *"
    > but it returns blank what do you think is the problem
    > I used the button to remove the filter but when I hit print it prints blank
    > rather than to print all locations.
    > What do u think?
    >
    > "schasteen" wrote:
    >
    > > DoCmd.OpenReport "reportName", acViewNormal, , "[location] ='" &
    > > Me![ComboBox] & "'"
    > >
    > > "Levans digital" wrote:
    > >
    > > > Hello Chasteen,
    > > >
    > > > Thanks very much.
    > > > It works great I went ahead and use the combo as you mentioned. One more
    > > > question How can I print the filtered form to a report must I put VBA in the
    > > > report of simply base it on locationstbl?
    > > >
    > > > "schasteen" wrote:
    > > >
    > > > > On the click event of your button
    > > > > Me.Filter = "[location] = 'A2'"
    > > > > Me.FilterOn = True
    > > > >
    > > > > It would be easier to have a combo box that has the locations that the user
    > > > > selects and the filter
    > > > >
    > > > > Me.Filter = "[location] = '" & Me![ComboBox] & "'"
    > > > > Me.FilterOn = True
    > > > >
    > > > > Then a button to remove the filter
    > > > > Me.FilterOn = False
    > > > >
    > > > >
    > > > > "Levans digital" wrote:
    > > > >
    > > > > > Help Please?
    > > > > >
    > > > > > Status:
    > > > > > I have a table called "Locationtbl" in that table their is a field "location"
    > > > > > I enter Test like A1, A2, C2, etc.. which are shelf # in an actual storeroom.
    > > > > > For example 1 box Pens will be stored in Shelf "A2"
    > > > > >
    > > > > > On a form based on the table can I press lets say a toggle or command button
    > > > > > to query or filter for only the items on a specific shelf?
    > > > > >
    > > > > > Lets say I have a button called "Shelf A2" and when I press it only the
    > > > > > items that has been placed on Shelf "A2" be returned.
    > > > > >
    > > > > > On my form I already have all the buttons I have "A1" A2 A3 A4 and B1, B2 B3
    > > > > > B4 and C1 C2 C3 C4.
    > > > > >
    > > > > > Help
     

Share This Page