using filter on form open

jmersing

Well-known Member
Joined
Apr 14, 2004
Messages
887
I'm using a function to get the name of the logged on user and am storing it in a textbox called USER. The form name is frmMain, the recordsource is qryMain, the field in the query that should be filtered is qryMain.requestor. I would like the form to filter the data by the value that comes up in the user field.

Meaning that the person who opens the form is taken to their records only, and can navigate through their records only.

I was trying on Form open event

me.filter = [requestor] = me.user & " "
me.filteron = true

Can't seem to fget it to work

Thanks
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Hi.

Don't know if this'll help (I'm a virtual newbie), but on a database I've built, I use a query as a filter instead. This query runs the filter using the name from a text box, and the form shows the results of the query rather than filtered raw data.

I did this by putting the query name in the Filter Name section of the macro design screen.

Seems to work ok for me. Don't know about the code side of it, up until recently, I was just using the macro pull-down menus! :cry:

CSBBB. :biggrin:
 
Upvote 0
Hi, following on from CSBBB, rather than filtering at the form level you can filter at the underlying query level by passing a value from a form (i.e. either a login form or a form stating "you are logged in as ....") to a query which would give you the results you want on the main form.

There is an MS article here, about half way down is a heading titled "Creating a form to supply parameters to a query" - have a read of that section. What you are trying to do is not too dissimilar to a dialogue box.

There may be a more direct way of doing this and I would be interested to hear alternative ways of doing this from other posters.

HTH, Andrew. :)
 
Upvote 0

Forum statistics

Threads
1,221,831
Messages
6,162,252
Members
451,757
Latest member
iours

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top