D
Duane
I would like to add a field from a third table and sum the field, but I am
having trouble with the syntax. I was wondering if someone could help me
with it?
The third table is called tblOvertime. It is joined to the Employee table
on the HRMN fields. I would like to SUM the Hours field in tblOvertime.
The first RecordSource (my starting point) works fine for my report.
Me.RecordSource = "SELECT Employee.HRMN, Employee.Group, " _
& "[LastName] & ', ' & [FirstName] & ' ' & " _
& "[MiddleInitial] AS EmpName, " _
& "Employee.Telephone, Employee.Shift, NES,
& "Employee.TotHours, Employee.TotHours, " _
& "Employee.Group " _
& "FROM Employee " _
& "INNER JOIN Rot " _
& "ON Employee.Group = ROT.Group " _
& "WHERE ROT.[MOD" & intMod & "] = 1 " _
& "AND Employee.[" & Forms!frm_Switchboard!MyList & "] = -1 " _
& "AND Employee.[" & Forms!frm_Switchboard!MyList & "H] > 0"
This is the one that is messed up.
Me.RecordSource = "SELECT Employee.HRMN, Employee.Group, " _
& "[LastName] & ', ' & [FirstName] & ' ' & [MiddleInitial] AS
EmpName, " _
& "Employee.Telephone, Employee.Shift, Employee.NES, Rot.MOD6, " _
& "Sum(tblOvertime.Hours) AS SumOfHours, " _
& "FROM Rot INNER JOIN (Employee INNER JOIN tblOvertime " _
& "ON Employee.HRMN = tblOvertime.HRMN) ON " _
& "Rot.Group = Employee.Group " _
& "GROUP BY Employee.HRMN, Employee.Group, " _
& "[LastName] & ', ' & [FirstName] & ' ' & [MiddleInitial], " _
& "Employee.Telephone, Employee.Shift, Employee.NES " _
& "WHERE ROT.[MOD" & intMod & "] = 1 "_
& " AND Employee.[" & Forms!frm_Switchboard!MyList & "] = -1 " _
& "AND Employee.[" & Forms!frm_Switchboard!MyList & "H] > 0"
I know this is probably written totally wrong, but I am trying to learn. I
am receiving an error for a reserved word, argument name misspelled, or the
punctuation is incorrect. I put more line continuations in here then what
is actually in my code, for readability purposes.
Any help would be greatly appreciated.
I previously posted this in the forum for MS Access Reports, but there
doesn't appear to be as much activity there as there is here.
having trouble with the syntax. I was wondering if someone could help me
with it?
The third table is called tblOvertime. It is joined to the Employee table
on the HRMN fields. I would like to SUM the Hours field in tblOvertime.
The first RecordSource (my starting point) works fine for my report.
Me.RecordSource = "SELECT Employee.HRMN, Employee.Group, " _
& "[LastName] & ', ' & [FirstName] & ' ' & " _
& "[MiddleInitial] AS EmpName, " _
& "Employee.Telephone, Employee.Shift, NES,
& "Employee.TotHours, Employee.TotHours, " _
& "Employee.Group " _
& "FROM Employee " _
& "INNER JOIN Rot " _
& "ON Employee.Group = ROT.Group " _
& "WHERE ROT.[MOD" & intMod & "] = 1 " _
& "AND Employee.[" & Forms!frm_Switchboard!MyList & "] = -1 " _
& "AND Employee.[" & Forms!frm_Switchboard!MyList & "H] > 0"
This is the one that is messed up.
Me.RecordSource = "SELECT Employee.HRMN, Employee.Group, " _
& "[LastName] & ', ' & [FirstName] & ' ' & [MiddleInitial] AS
EmpName, " _
& "Employee.Telephone, Employee.Shift, Employee.NES, Rot.MOD6, " _
& "Sum(tblOvertime.Hours) AS SumOfHours, " _
& "FROM Rot INNER JOIN (Employee INNER JOIN tblOvertime " _
& "ON Employee.HRMN = tblOvertime.HRMN) ON " _
& "Rot.Group = Employee.Group " _
& "GROUP BY Employee.HRMN, Employee.Group, " _
& "[LastName] & ', ' & [FirstName] & ' ' & [MiddleInitial], " _
& "Employee.Telephone, Employee.Shift, Employee.NES " _
& "WHERE ROT.[MOD" & intMod & "] = 1 "_
& " AND Employee.[" & Forms!frm_Switchboard!MyList & "] = -1 " _
& "AND Employee.[" & Forms!frm_Switchboard!MyList & "H] > 0"
I know this is probably written totally wrong, but I am trying to learn. I
am receiving an error for a reserved word, argument name misspelled, or the
punctuation is incorrect. I put more line continuations in here then what
is actually in my code, for readability purposes.
Any help would be greatly appreciated.
I previously posted this in the forum for MS Access Reports, but there
doesn't appear to be as much activity there as there is here.