Filter Results of form on Load

mcgraw

Registered User.
Local time
Today, 12:02
Joined
Nov 13, 2009
Messages
77
I have a datasheet form in Access 2007 that I need to filter on load to only return results for the person currently logged in. The form is going to be used to show what items are due in the coming week and be sort of a time management "solution" for staff.

I have a module fsUserName which I found on this site that will return the current user logged in, so what I need to do now is say Where fsUserName = Contacts.Login_Name and apply that filter when the form is loaded.

I am not sure how to write a filter, (or event procedure maybe?) that will give me the results I need.

I would appreciate some guidance! Thanks! :D
 
One way would be to base the form on a query instead of the table, and include a criteria in the query.
 
One way would be to base the form on a query instead of the table, and include a criteria in the query.

The form is actually based off a query, but I don't know any way for the query to return values based on a function in VB?

Here's the query I'm using:

SELECT Issues.ID, Issues.Title, Issues.Model, Issues.Due_Date, Issues.Status, Contacts.login_name
FROM Contacts INNER JOIN Issues ON Contacts.ID = Issues.[Assigned To]
WHERE (((DatePart("ww",[Due_Date]))=DatePart("ww",Date())) AND ((Year([Due_Date]))=Year(Date())));

If there is a way for it to say WHERE (existing criteria) AND contacts.login_name = fOSUsername; then that would be great!
 
Presuming that function is in a standard module, you should be able to do just that.

WHERE (((DatePart("ww",[Due_Date]))=DatePart("ww",Date())) AND ((Year([Due_Date]))=Year(Date()))) AND contacts.login_name = fOSUsername()
 
Ok, well now I just feel stupid!

When I tried that before I mistyped something and it threw up on me...but pasting your line in there worked.

Yup...feeling pretty stupid right now.

I bow down to the superior intellect! Thanks for the help! :-)
 
LOL! Superior intellect, or "made the same mistake 1000 times and finally learned from it"? My vote is for the second. :p
 

Users who are viewing this thread

Back
Top Bottom