Working with Filters in code

  • Thread starter Thread starter Ayo
  • Start date Start date
A

Ayo

I have a form that I use to input my data. I just added a cmbBox to the form
and I want to you it to filter the database. So that when I select a value in
the cmbBox I want the Record at the bottom of the form to show the number of
data that as being filtered so that I can then go through them and make my
edits.
How do I do this?
Thanks
 
Drop the following in the afterupdate or click event of your combobox

Me.Form.Filter = "[MY_FIELD] = '" & Me.MY_COMBO.Value & "'"
Me.Form.FilterOn = True
 
Drop something like the following in the afterupdate event of your combobox

Me.Form.Filter = "[F1] = '" & Me.Combo0.Value & "'"
Me.Form.FilterOn = True
 
Thanks Lance. iwill try these and let you know how it goes.

Lance said:
Drop something like the following in the afterupdate event of your combobox

Me.Form.Filter = "[F1] = '" & Me.Combo0.Value & "'"
Me.Form.FilterOn = True

Ayo said:
I have a form that I use to input my data. I just added a cmbBox to the form
and I want to you it to filter the database. So that when I select a value in
the cmbBox I want the Record at the bottom of the form to show the number of
data that as being filtered so that I can then go through them and make my
edits.
How do I do this?
Thanks
 
wow.. thought I cancelled those first two before posting. Just ignore them :P

Ayo said:
Thanks Lance. iwill try these and let you know how it goes.

Lance said:
Drop something like the following in the afterupdate event of your combobox

Me.Form.Filter = "[F1] = '" & Me.Combo0.Value & "'"
Me.Form.FilterOn = True

Ayo said:
I have a form that I use to input my data. I just added a cmbBox to the form
and I want to you it to filter the database. So that when I select a value in
the cmbBox I want the Record at the bottom of the form to show the number of
data that as being filtered so that I can then go through them and make my
edits.
How do I do this?
Thanks
 
That works great. Thank you. Thank you. Thank you !!!!!!

Lance said:
Drop something like the following in the afterupdate event of your combobox

Me.Form.Filter = "[F1] = '" & Me.Combo0.Value & "'"
Me.Form.FilterOn = True

Ayo said:
I have a form that I use to input my data. I just added a cmbBox to the form
and I want to you it to filter the database. So that when I select a value in
the cmbBox I want the Record at the bottom of the form to show the number of
data that as being filtered so that I can then go through them and make my
edits.
How do I do this?
Thanks
 
Thanks.
Need help with something else, hope you can help. I have 2 cmbBoxes and I
want one to update the other.
cmbBox1:
Row Sorce Type = Field List
Row Source = Invoice Tracker

cmbBox2:
Row Sorce Type = Table/Query
Row Source = SELECT DISTINCT [Invoice Tracker].cmbTrackerFields.value FROM
[Invoice Tracker] ORDER BY [Invoice Tracker].cmbTrackerFields;

What I want to do is, when I select a field title in cmbBox1, I want cmbBox2
to be updated with a list of all (distinct) the values in the field. I think
I am getting the Row Source property value wrong.
Can you take a look and tell me what I am doing wrong? Thanks.

Lance said:
wow.. thought I cancelled those first two before posting. Just ignore them :P

Ayo said:
Thanks Lance. iwill try these and let you know how it goes.

Lance said:
Drop something like the following in the afterupdate event of your combobox

Me.Form.Filter = "[F1] = '" & Me.Combo0.Value & "'"
Me.Form.FilterOn = True

:

I have a form that I use to input my data. I just added a cmbBox to the form
and I want to you it to filter the database. So that when I select a value in
the cmbBox I want the Record at the bottom of the form to show the number of
data that as being filtered so that I can then go through them and make my
edits.
How do I do this?
Thanks
 
If I'm understanding what you're doing correctly..

You seem to be missing a where clause. In the afterupdate even of cmbbox1
you're going to need to set the rowsource with something like..

If your ID is a string then use:
Me.cmbBox2.RowSource = "SELECT DISTINCT [Invoice
Tracker].cmbTrackerFields.value FROM [Invoice Tracker] WHERE [Invoice
Tracker].[WHATEVER ID FIELD] = '" & me.cmbbox1.value & '" ORDER BY [Invoice
Tracker].cmbTrackerFields"

If it's numeric ( no quotes needed around criteria value ):
Me.cmbBox2.RowSource = "SELECT DISTINCT [Invoice
Tracker].cmbTrackerFields.value FROM [Invoice Tracker] WHERE [Invoice
Tracker].[WHATEVER ID FIELD] = " & me.cmbbox1.value & ' ORDER BY [Invoice
Tracker].cmbTrackerFields"

Ayo said:
Thanks.
Need help with something else, hope you can help. I have 2 cmbBoxes and I
want one to update the other.
cmbBox1:
Row Sorce Type = Field List
Row Source = Invoice Tracker

cmbBox2:
Row Sorce Type = Table/Query
Row Source = SELECT DISTINCT [Invoice Tracker].cmbTrackerFields.value FROM
[Invoice Tracker] ORDER BY [Invoice Tracker].cmbTrackerFields;

What I want to do is, when I select a field title in cmbBox1, I want cmbBox2
to be updated with a list of all (distinct) the values in the field. I think
I am getting the Row Source property value wrong.
Can you take a look and tell me what I am doing wrong? Thanks.

Lance said:
wow.. thought I cancelled those first two before posting. Just ignore them :P

Ayo said:
Thanks Lance. iwill try these and let you know how it goes.

:

Drop something like the following in the afterupdate event of your combobox

Me.Form.Filter = "[F1] = '" & Me.Combo0.Value & "'"
Me.Form.FilterOn = True

:

I have a form that I use to input my data. I just added a cmbBox to the form
and I want to you it to filter the database. So that when I select a value in
the cmbBox I want the Record at the bottom of the form to show the number of
data that as being filtered so that I can then go through them and make my
edits.
How do I do this?
Thanks
 
Thanks Lance. But I am still having a problem. This is what I have so far,
what do you think is wrong? I know it has to do with "[Invoice
Tracker].cmbTrackerFields.value = & Me.cmbTrackerFields.value" but I don't
know how to fix it. Is there something like a field id to use here?
Me.cmbFieldValues.RowSource = "SELECT DISTINCT [Invoice
Tracker].cmbTrackerFields.value FROM [Invoice Tracker] WHERE [Invoice
Tracker].cmbTrackerFields.value = & Me.cmbTrackerFields.value & ORDER BY
[Invoice Tracker].cmbTrackerFields.value"



Lance said:
If I'm understanding what you're doing correctly..

You seem to be missing a where clause. In the afterupdate even of cmbbox1
you're going to need to set the rowsource with something like..

If your ID is a string then use:
Me.cmbBox2.RowSource = "SELECT DISTINCT [Invoice
Tracker].cmbTrackerFields.value FROM [Invoice Tracker] WHERE [Invoice
Tracker].[WHATEVER ID FIELD] = '" & me.cmbbox1.value & '" ORDER BY [Invoice
Tracker].cmbTrackerFields"

If it's numeric ( no quotes needed around criteria value ):
Me.cmbBox2.RowSource = "SELECT DISTINCT [Invoice
Tracker].cmbTrackerFields.value FROM [Invoice Tracker] WHERE [Invoice
Tracker].[WHATEVER ID FIELD] = " & me.cmbbox1.value & ' ORDER BY [Invoice
Tracker].cmbTrackerFields"

Ayo said:
Thanks.
Need help with something else, hope you can help. I have 2 cmbBoxes and I
want one to update the other.
cmbBox1:
Row Sorce Type = Field List
Row Source = Invoice Tracker

cmbBox2:
Row Sorce Type = Table/Query
Row Source = SELECT DISTINCT [Invoice Tracker].cmbTrackerFields.value FROM
[Invoice Tracker] ORDER BY [Invoice Tracker].cmbTrackerFields;

What I want to do is, when I select a field title in cmbBox1, I want cmbBox2
to be updated with a list of all (distinct) the values in the field. I think
I am getting the Row Source property value wrong.
Can you take a look and tell me what I am doing wrong? Thanks.

Lance said:
wow.. thought I cancelled those first two before posting. Just ignore them :P

:

Thanks Lance. iwill try these and let you know how it goes.

:

Drop something like the following in the afterupdate event of your combobox

Me.Form.Filter = "[F1] = '" & Me.Combo0.Value & "'"
Me.Form.FilterOn = True

:

I have a form that I use to input my data. I just added a cmbBox to the form
and I want to you it to filter the database. So that when I select a value in
the cmbBox I want the Record at the bottom of the form to show the number of
data that as being filtered so that I can then go through them and make my
edits.
How do I do this?
Thanks
 

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

Back
Top