Randomblink
The Irreverent Reverend
- Local time
- Today, 15:12
- Joined
- Jul 23, 2001
- Messages
- 279
Ok...
This is hard to explain...
I have two tables and one form I am using here.
Table #1: Employee Table
Table #2: Department Table
The Employee table is linked to the Department table by a Dept_ID field that is in both tables.
I have a function: GetNTUser() that grabs the NT Logon ID.
What I want to do, is as the user opens the form.
The form runs the GetNTUser() function.
Then it checks that ID against the Employee table.
It will find the Employee who matches up to the NT Logon.
Then it grabs the Dept_ID that that Employee has.
It then checks the Department table.
It finds the Department with that Dept_ID.
It assigns the label caption of choice to be that Department Name.
Here is the SQL code that finds the record containing the right employee and therefore the correct department.
SELECT tbl_Employee.Empl_NTLogon, tbl_Department.Dept_Name FROM tbl_Department INNER JOIN tbl_Employee ON tbl_Department.Dept_ID = tbl_Employee.Dept_ID WHERE (((tbl_Employee.Empl_NTLogon)=GetNTUser()));"
But, I cannot seem to run this code and then assign the tbl_Department.Dept_Name to the label.caption...?
Can someone help?
I can create a listbox that has the above SQL as it's code.
Then set it up with two columns.
Put the Dept_Name as Column(2).
Bind Column(2) to the listbox.
Then set the lbl_DepartmentName.Cation = listbox
But that is a massive workaround...
I am sure there is code that will do the same thing...
I NEED that code...
This is hard to explain...
I have two tables and one form I am using here.
Table #1: Employee Table
Table #2: Department Table
The Employee table is linked to the Department table by a Dept_ID field that is in both tables.
I have a function: GetNTUser() that grabs the NT Logon ID.
What I want to do, is as the user opens the form.
The form runs the GetNTUser() function.
Then it checks that ID against the Employee table.
It will find the Employee who matches up to the NT Logon.
Then it grabs the Dept_ID that that Employee has.
It then checks the Department table.
It finds the Department with that Dept_ID.
It assigns the label caption of choice to be that Department Name.
Here is the SQL code that finds the record containing the right employee and therefore the correct department.
SELECT tbl_Employee.Empl_NTLogon, tbl_Department.Dept_Name FROM tbl_Department INNER JOIN tbl_Employee ON tbl_Department.Dept_ID = tbl_Employee.Dept_ID WHERE (((tbl_Employee.Empl_NTLogon)=GetNTUser()));"
But, I cannot seem to run this code and then assign the tbl_Department.Dept_Name to the label.caption...?
Can someone help?
I can create a listbox that has the above SQL as it's code.
Then set it up with two columns.
Put the Dept_Name as Column(2).
Bind Column(2) to the listbox.
Then set the lbl_DepartmentName.Cation = listbox
But that is a massive workaround...
I am sure there is code that will do the same thing...
I NEED that code...