Press button to filter or query a form

G

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
 
G

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
 
G

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 said:
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 said:
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
 
G

Guest

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

Levans digital said:
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 said:
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 said:
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
 
G

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 said:
DoCmd.OpenReport "reportName", acViewNormal, , "[location] ='" &
Me![ComboBox] & "'"

Levans digital said:
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 said:
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


:

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
 
G

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 said:
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 said:
DoCmd.OpenReport "reportName", acViewNormal, , "[location] ='" &
Me![ComboBox] & "'"

Levans digital said:
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?

:

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


:

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top