Eloquent Programming

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm looking for an eloquent way to pull data from multiple queries based on
an individuals log-in using VB.

I have a database I created to track training for multiple departments and
currently I have it set up to open a form/query based on an individuals
log-in keeping the departments seperate. This way, when one department loggs
into the database, they only see individuals assigned to there department.

The problem is, I have one form/query for each department (24 forms/queries
total) but I want to streamline this to make it more eloquent. What I would
like to know how to do is this, pull data from a specific query for this one
form based on a users login. If the user is in HR, then I want the form to
pull data from the HR query. If the user is in R&D, I want the form to pull
data from the R&D query.

Make sense?

Thanks in advance for any assistance provided :-)
 
Hopefully all your data's in the same table, and not 24 separate tables. If
not, redesign your tables so that that's the case.

Do you have some way of knowing what department is logging into the
database? Can you put the department name on a form somewhere? (The form
doesn't even have to be open...)

Redo your queries so that they use the department name on the form above as
a parameter. That'll limit what's returned to the forms and reports to being
only what applies to the specific department.
 
Seems to me you should be able to do this with one query, using both the
department and the userID as criteria. On my website
(www.rogersaccesslibrary.com), there is a small Access sample database
called: "UserSeesOnlyHisRecords.mdb" which does something similar. It uses
a hidden form called FLogin that opens on startup to hold the user name. If
you added code to hold the department name, you should be able to base a
query on both the department and user. BTW, yould have to have a table with
the userID and department.

--
--Roger Carlson
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
Presuming that all users are in one database (if not, make it so #1), each
user should be assigned to a department by a field on the record which points
to a department lookup table.

When the individual logs in, a global variable is set for the department to
which they are assigned. For every query, use this global variable a
criterion. If you are using stored queries, then write this variable to a
hidden text box on the form and use the hidden text box in the query. If you
are using VBA code on a particular event, then the global variable will
suffice.

r,

~ Bob Bonta ~
 
Back
Top