ChrisCalvert
Technical User
Hello, this is long and involved, so bear with me....
I have two tables tblLogins and tblEmployeeData. tblLogins has fields LoginID (a number used to login to phone system, this is a limited number we have, it is the key field of this table) and EmpNo (employee number). tblEmployeeData has several fields but I am only concerned with EmpNo (same number as above). I have two forms, frmNewAgent and frmBrowse, both forms based on tblEmployeeData. I need to have a button on frmNewAgent that assigns the next availible (the EmpNo field is blank) LoginID from the tblLogins to this employee by writing the EmpNo (from the current record on the tblEmployeeData table) to that null EmpNo field (on the tblLogins). That way I can assign the new employee one of the availible logins that is not assigned to any other employee. It was suggested to me to use Max() in the query and I think I have the query correct, but I am unsure of how to implement this. I want it to be as simple as possible (it does not seem very simple at this point). I have the following query
UPDATE tblLogins SET tblLogins.EmpNo = ??Not Sure, I think Me!EmpNo?? WHERE (((tblLogins.EmpNo)=(SELECT max(LoginID) from tblLogins where isnull(tblLogins.LoginID))));
But I don't really know what to do with the query. Some how I need to make this execute and update the tblLogins.EmpNo.
ALSO: I have an unbound textbox on the frmBrowse that I want to query the tblLogins and match the LoginID to the EmpNo on the form. (As opposed to copying the assigned LoginID to a field in the tblEmployeeData, I just want to query off the tblLogins) I have the control set to :
=SELECT tblLogins.LoginID
FROM tblLogins
WHERE (((tblLogins.EmpNo)=[Forms]![frmBrowse]![EmpNo]));
But it tells me there is a problem with the syntax of the subquery (WHAT subquery?) and to place parenthesis around the subquery.
Can anyone help with either of these issues? I would greatly appreciate it.
-chris
I have two tables tblLogins and tblEmployeeData. tblLogins has fields LoginID (a number used to login to phone system, this is a limited number we have, it is the key field of this table) and EmpNo (employee number). tblEmployeeData has several fields but I am only concerned with EmpNo (same number as above). I have two forms, frmNewAgent and frmBrowse, both forms based on tblEmployeeData. I need to have a button on frmNewAgent that assigns the next availible (the EmpNo field is blank) LoginID from the tblLogins to this employee by writing the EmpNo (from the current record on the tblEmployeeData table) to that null EmpNo field (on the tblLogins). That way I can assign the new employee one of the availible logins that is not assigned to any other employee. It was suggested to me to use Max() in the query and I think I have the query correct, but I am unsure of how to implement this. I want it to be as simple as possible (it does not seem very simple at this point). I have the following query
UPDATE tblLogins SET tblLogins.EmpNo = ??Not Sure, I think Me!EmpNo?? WHERE (((tblLogins.EmpNo)=(SELECT max(LoginID) from tblLogins where isnull(tblLogins.LoginID))));
But I don't really know what to do with the query. Some how I need to make this execute and update the tblLogins.EmpNo.
ALSO: I have an unbound textbox on the frmBrowse that I want to query the tblLogins and match the LoginID to the EmpNo on the form. (As opposed to copying the assigned LoginID to a field in the tblEmployeeData, I just want to query off the tblLogins) I have the control set to :
=SELECT tblLogins.LoginID
FROM tblLogins
WHERE (((tblLogins.EmpNo)=[Forms]![frmBrowse]![EmpNo]));
But it tells me there is a problem with the syntax of the subquery (WHAT subquery?) and to place parenthesis around the subquery.
Can anyone help with either of these issues? I would greatly appreciate it.
-chris