Forms and filters

Pilgrim

Programmer Analyst
Local time
Today, 12:23
Joined
Oct 12, 2004
Messages
5
Folks,
I've got an odd request here - I have a form that we use for showing events for each employee for the month and I want to be able to double click on the employee name and show only the events for that employee. I can't use the right click and filter option because this database will be used by non-technical users and that function has been disabled for their view of the database.
Can anyone help me out?
Thanks in advance,
Trey
 
In the double-click event of the field:

Me.Filter = "Where clause"
Me.FilterOn = True
 
Rob,
That does help but the kicker seems to be getting the value in that field into the where clause. Any insights on that?
Thanks,
 
No problem. Are you familiar with building strings? It's a good skill to have in development. Take for example the line of code below:

Me.Filter = "State = 'NY'"

You're passing a string to the filter property of the form which it then compiles to figure out what to filter.

You can do all kinds of things with strings in terms of manipulating them but here's an example of what you would need:

Me.Filter = "State = '" & Me!StateTextBox & "'"

It builds the string by first taking the part in the first set of double quotes (State = '), adds the value of Me!StateTextBox (NY), and then adds the trailing single quote ('). This creates the string it needs and assigns it to the filter property.

So what you need to do is change the word State to the name of the field in the recordset (if there's spaces in the name surround it with brackets) and change StateTextBox to the name of the field that you want to get the value from.

Also remember syntax... Three types; text, number, date. If the above was for a date you'd use this:

"Date = #" & Me!DateBox & "#"

For a number it would be:

"ID = " & Me!IDField
 

Users who are viewing this thread

Back
Top Bottom