Help w/ loop & directing data to field
-
Hi! I am in WAY over my head here and was hoping someone could help me out. I need a db that is like a time clock. Employees clock in and out, time is entered into table, and reports are run to show hours worked. I have no formal training in computers, so please bear with me :) One of my current problems is directing the data to the login or logout field. It only enters into the login field now. My next problem is that I need to tell the user his time is entered, and then refresh the form for the next user. I tried the Docmd.OpenForm, but it opens a new form on top of the previous one, creating quite a mess! I read about loop while or loop until, but...basically I'm clueless :sigh: . One more problem---it doesn't always work. I don't see the rhyme or reason, but sometimes the time is entered, sometimes not, and sometimes it is entered for ALL employees. Can anyone help me? Please be gentle, remember, I am new to this! The set up is: tblStaff StaffLoginName StaffPassword tblLoginRecords LogStaffLoginName LogPasswordEntered LogINTime <---(all times currently enter here) LogOUTTime LogProblem (yes/no check) frmLogin bound controls: Your Name [LogStaffLoginName] Enter Password [LogPasswordEntered] (hidden) LogTime [LogINTime] (hidden) LogDate [LogINDate] Log IN (cmd8)and Log OUT (cmd 9) buttons (code follows) (hidden) yes/no check box for LogProblem ___________________________________________________________________________ Private Sub Command8_Click() On Error GoTo Err_CmdLogin_Click If [LogStaffLoginName] = DLookup("[StaffLoginName]", "TblStaff", "[StaffPassword]=forms!frmlogin!LogPasswordEntered") Then MsgBox "Your time has been logged.", vbOKOnly, "Login Confirmation." DoCmd.OpenForm "frmLogin", acNormal Else Me!LogProblem = -1 MsgBox "Incorrect UserName or Password. Please try again.", vbOKOnly, "Login Error." DoCmd.OpenForm "frmLogin" End If Forms!frmLogin.Visible = False Exit_CmdLogin_Click: Exit Sub Err_CmdLogin_Click: MsgBox Err.Description Resume Exit_CmdLogin_Click End Sub Private Sub Command9_Click() On Error GoTo Err_CmdLogout_Click If [LogStaffLoginName] = DLookup("[StaffLoginName]", "TblStaff", "[StaffPassword]=forms!frmlogin!LogPasswordEntered") Then MsgBox "Your time has been logged.", vbOKOnly, "Logout Confirmation." DoCmd.Save acTable, "[LogOUTTime]", "tblLoginRecords" Else Me!LogProblem = -1 MsgBox "Incorrect UserName or Password. Please try again.", vbOKOnly, "Logout Error." DoCm
-
Hi! I am in WAY over my head here and was hoping someone could help me out. I need a db that is like a time clock. Employees clock in and out, time is entered into table, and reports are run to show hours worked. I have no formal training in computers, so please bear with me :) One of my current problems is directing the data to the login or logout field. It only enters into the login field now. My next problem is that I need to tell the user his time is entered, and then refresh the form for the next user. I tried the Docmd.OpenForm, but it opens a new form on top of the previous one, creating quite a mess! I read about loop while or loop until, but...basically I'm clueless :sigh: . One more problem---it doesn't always work. I don't see the rhyme or reason, but sometimes the time is entered, sometimes not, and sometimes it is entered for ALL employees. Can anyone help me? Please be gentle, remember, I am new to this! The set up is: tblStaff StaffLoginName StaffPassword tblLoginRecords LogStaffLoginName LogPasswordEntered LogINTime <---(all times currently enter here) LogOUTTime LogProblem (yes/no check) frmLogin bound controls: Your Name [LogStaffLoginName] Enter Password [LogPasswordEntered] (hidden) LogTime [LogINTime] (hidden) LogDate [LogINDate] Log IN (cmd8)and Log OUT (cmd 9) buttons (code follows) (hidden) yes/no check box for LogProblem ___________________________________________________________________________ Private Sub Command8_Click() On Error GoTo Err_CmdLogin_Click If [LogStaffLoginName] = DLookup("[StaffLoginName]", "TblStaff", "[StaffPassword]=forms!frmlogin!LogPasswordEntered") Then MsgBox "Your time has been logged.", vbOKOnly, "Login Confirmation." DoCmd.OpenForm "frmLogin", acNormal Else Me!LogProblem = -1 MsgBox "Incorrect UserName or Password. Please try again.", vbOKOnly, "Login Error." DoCmd.OpenForm "frmLogin" End If Forms!frmLogin.Visible = False Exit_CmdLogin_Click: Exit Sub Err_CmdLogin_Click: MsgBox Err.Description Resume Exit_CmdLogin_Click End Sub Private Sub Command9_Click() On Error GoTo Err_CmdLogout_Click If [LogStaffLoginName] = DLookup("[StaffLoginName]", "TblStaff", "[StaffPassword]=forms!frmlogin!LogPasswordEntered") Then MsgBox "Your time has been logged.", vbOKOnly, "Logout Confirmation." DoCmd.Save acTable, "[LogOUTTime]", "tblLoginRecords" Else Me!LogProblem = -1 MsgBox "Incorrect UserName or Password. Please try again.", vbOKOnly, "Logout Error." DoCm
Hello Tiff: I have a didn't see a field for the date in the logins table and I think that in the same table you only need the user name to link this field whit the one in the staff table, to display only one time the form you can check if its display or use modal mode on when you display the from, one question what version of VB your using?. JA
-
Hello Tiff: I have a didn't see a field for the date in the logins table and I think that in the same table you only need the user name to link this field whit the one in the staff table, to display only one time the form you can check if its display or use modal mode on when you display the from, one question what version of VB your using?. JA
Hi JA! Thank you for looking :-D The logINTime and logOUTTime are date and time fields. I thought this would be easier for calculations. They are set as 01/01/2004 12:00 in the same field. I am using Access 2000 w/ VB6. I have no special talents. I am only passionately curious. --Albert Einstein