Employee Table and retrieving data (1 Viewer)

sladetroityer

Registered User.
Local time
Today, 08:16
Joined
Oct 26, 2011
Messages
149
I have created an employee database for many different groups (departments) to use and I'd like to create a button that restricts or filters the data from the employee table for particular departments. Exampe: I have a form with all of the different groups labeled with cmd buttons and upon clicking the cmd botton I want only the Chassis data to be sent to the Main form instead of the main form showing all of the employees.
 

sladetroityer

Registered User.
Local time
Today, 08:16
Joined
Oct 26, 2011
Messages
149
No, the first form is where I'd like the users to specify which group they work with by clicking that button which would bring them to the MAIN form only showing the records that apply.
 

sladetroityer

Registered User.
Local time
Today, 08:16
Joined
Oct 26, 2011
Messages
149
The records are for people tracking. HR has their own system and won't let anybody access it. There are no confidential records to worry about. The link you sent me seems to have the right idea but I'm not sure what would go into the VBA code for my use.
 

vbaInet

AWF VIP
Local time
Today, 16:16
Joined
Jan 22, 2010
Messages
26,374
Using the example in your first post, filter the relevant field by 'Chassis' (for example).
 

sladetroityer

Registered User.
Local time
Today, 08:16
Joined
Oct 26, 2011
Messages
149
So the string would look like this?
DoCMD.openForm "frmNavagationMain", , ,"FinancialDepartment = '1250-0850" & Me.ControlName & " ' "
 

sladetroityer

Registered User.
Local time
Today, 08:16
Joined
Oct 26, 2011
Messages
149
What if I wanted to use a query in that expression? I've already created all the queries for each department. Is that possible?
 

vbaInet

AWF VIP
Local time
Today, 16:16
Joined
Jan 22, 2010
Messages
26,374
Yes something like that but without the spaces here --> & "'"
What is the 1250-0850 doing there?
 

sladetroityer

Registered User.
Local time
Today, 08:16
Joined
Oct 26, 2011
Messages
149
1250-0850 is the department number but I think you're telling me to replace that with the query.
 

vbaInet

AWF VIP
Local time
Today, 16:16
Joined
Jan 22, 2010
Messages
26,374
I wasn't sure what you were doing with that number and Me.ControlName. Your code should read:
Code:
DoCMD.openForm "frmNavagationMain", , ,"FinancialDepartment = '1250-0850'"
 

sladetroityer

Registered User.
Local time
Today, 08:16
Joined
Oct 26, 2011
Messages
149
That looks great, now what if I wanted to use a query called "qselChassisEmployeeInformation"

The query retrieves the correct data and I'd rather sue the query because there are about 20 to 30 department numbers for each group.
 

vbaInet

AWF VIP
Local time
Today, 16:16
Joined
Jan 22, 2010
Messages
26,374
Base a form on the query, open it as a Datasheet.
 

sladetroityer

Registered User.
Local time
Today, 08:16
Joined
Oct 26, 2011
Messages
149
Uggh, that's what I am trying to avoid. I don't want a form for every query. I want one form for all queries..... Is that possible.
 

vbaInet

AWF VIP
Local time
Today, 16:16
Joined
Jan 22, 2010
Messages
26,374
Which is why I gave you the code. One form based on a query, the code filters the form's Record Source when applied.
 

sladetroityer

Registered User.
Local time
Today, 08:16
Joined
Oct 26, 2011
Messages
149
Ok then one more issue. I have an employee table that has department info in each record which in turn is linked to the department number table which is where the queries are pulling from. The info in the Department table is like this:
1250-0860 = AVE-AVE: Advanced Engineering and because there are multiple department number for AVE I am filtering by Department Description as opposed to Dept. #. So my queries all say Like AVE*
 

vbaInet

AWF VIP
Local time
Today, 16:16
Joined
Jan 22, 2010
Messages
26,374
And the problem is??

What does this "1250-0860 = AVE-AVE: Advanced Engineering" mean?

Use Department Number to filter your query.
 

Users who are viewing this thread

Top Bottom