INSERT INTO Paychex ( User_Name, Last_Name, First_Name, Earnings_Code, Hours_Worked, Store_Id )
SELECT dbo_User_Tb.User_Name, dbo_Employee_Tb.Last_Name, dbo_Employee_Tb.First_Name, IIf([Earnings_Id]="9000","1","2") AS Earnings_Code, Sum(dbo_Payroll_Hours_Tb.Hours_Worked) AS SumOfHours_Worked, dbo_Payroll_Hours_Tb.Store_Id
FROM (dbo_Payroll_Hours_Tb INNER JOIN dbo_Employee_Tb ON dbo_Payroll_Hours_Tb.Employee_Id = dbo_Employee_Tb.Employee_Id) INNER JOIN dbo_User_Tb ON dbo_Employee_Tb.User_Id = dbo_User_Tb.User_Id
WHERE (((dbo_Payroll_Hours_Tb.Pay_Period_End_Date)=[Enter payroll ending date:]))
GROUP BY dbo_User_Tb.User_Name, dbo_Employee_Tb.Last_Name, dbo_Employee_Tb.First_Name, IIf([Earnings_Id]="9000","1","2"), dbo_Payroll_Hours_Tb.Store_Id;
----------------------------------------------------------------------------------------------------------------
Option Compare Database
Public Function CreateTextFile()
Dim strUser_Name As String * 6
Dim strLast_Name As String * 25
Dim strFirst_Name As String * 25
Dim strFiller1 As String * 6
Dim strFiller2 As String * 13
Dim strE As String * 3
Dim strEarnings_Code As String * 17
Dim strHours_Worked As String * 8
Dim strFiller3 As String * 14
Dim strStore_Id As String * 12
Dim strSecurity_Role_Id As String * 25
Dim mydb As DAO.Database, myset As DAO.Recordset
Dim intFile As Integer
Set mydb = CurrentDb()
Set myset = mydb.OpenRecordset("Paychex", dbOpenTable)
intFile = FreeFile
Open "c:\1753_TA.txt" For Output As intFile
Do Until myset.EOF
LSet strUser_Name = myset![User_Name]
RSet strLast_Name = myset![Last_Name]
RSet strFirst_Name = myset![First_Name]
RSet strFiller1 = myset![Filler1]
RSet strFiller2 = myset![Filler2]
RSet strE = myset![E]
RSet strEarnings_Code = myset![Earnings_Code]
RSet strHours_Worked = myset![Hours_Worked]
RSet strFiller3 = myset![Filler3]
RSet strStore_Id = myset![Store_Id]
Print #intFile, strUser_Name & strLast_Name & strFirst_Name & strFiller1 & strFiller2 & strE & strEarnings_Code & strHours_Worked & strFiller3 & strStore_Id
myset.MoveNext
Loop
Close intFile
myset.Close
mydb.Close
MsgBox "This Is The Broadbase Version!"
End Function
|