View Full Version : Global Variable?


TimE
05-01-2007, 07:54 AM
I have a table with username and site association (username: TimE, site: FTW). I have the code to determine the NTid which will be the same in the table. When I log on, I want my forms and queries to use certain tables (site specific). Is this possible?

boblarson
05-01-2007, 08:06 AM
If you have the NT username in the table, you can

Environ("username") to find the logon id.

There have been some who argue that environment variables can be manipulated, so that is not necessarily accurate, but I haven't had that problem. But, if you think you might, you can go to use this API instead:

http://www.mvps.org/access/api/api0008.htm

pbaldy
05-01-2007, 08:24 AM
Sure, though it could be argued that you shouldn't have separate tables for each site, rather one table with a field for site. That's if they have the same fields. In any case, you'd have to have code to modify the source of the forms as they open to do what you're asking.

Edit: sorry Bob, I started typing a while ago then the boss asked me a question.

TimE
05-01-2007, 08:26 AM
I am already using the fOSUsername() with no trouble. I would like to use a certain table based on my site that is associated with my username/NTid.


If tblSite.site="FTW", then use table tblFTW

As for the mutliple tables, the record count will run into the thousands very quickly with the multiple sites and not all sites have the same fields. I can join the tables and use a Site ID if this is the best way to approach it. I am open to any suggestions since this database is in its development and unfortutanely production (headaches!!!) stage right now.