..hope this helps - contains extra code.
INSERT INTO SecRptEnabledTable ( USER_ID, ReportModule, [Sec Type],
ReportsEnabled, [Module Desc], [Sec Type Desc], RptCode1, Desc1 )
SELECT SecRptEnabled_part2.USER_ID, SecRptEnabled_part2.Module AS
ReportModule, SecRptEnabled_part2.[Sec Type],
SecRptEnabled_part2.ReportsEnabled, [Menu Module].[Module Desc], [Menu
Sec Type].[Sec Type Desc], SecRptEnabled_part2.RptCode1,
SecRptEnabled_part2.Desc1
FROM (SecRptEnabled_part2 LEFT JOIN [Menu Sec Type] ON
SecRptEnabled_part2.[Sec Type] = [Menu Sec Type].[Sec Type]) LEFT JOIN
[Menu Module] ON SecRptEnabled_part2.Module = [Menu Module].Module
GROUP BY SecRptEnabled_part2.USER_ID, SecRptEnabled_part2.Module,
SecRptEnabled_part2.[Sec Type], SecRptEnabled_part2.ReportsEnabled, [Menu
Module].[Module Desc], [Menu Sec Type].[Sec Type Desc],
SecRptEnabled_part2.RptCode1, SecRptEnabled_part2.Desc1
HAVING (((SecRptEnabled_part2.[Sec Type]) Not In ("S","M")) AND (([Menu
Module].[Module Desc]) Is Not Null))
WITH OWNERACCESS OPTION;
Ken Snell (MVP) said:
What is the SQL statement of the "SecRptEnabled_part3" query?
--
Ken Snell
<MS ACCESS MVP>
See code below.
'This creates a recordset of users selected from AdvanSec RptsFrm
strSQL1 = "SELECT [USER_CODE] FROM SYSADM_APP_SECURITY " & _
"WHERE ([USER_CODE] >= """ & [Forms]![AdvanSec RptsFrm]![FromUser] &
_
""" And [USER_CODE] <= """ & [Forms]![AdvanSec RptsFrm]![ToUser] & _
""") WITH OWNERACCESS OPTION;"
'This loops through the user recordset appending _
each users reports to tblSecurityReportEnabled
Set rsUserList = db.OpenRecordset(strSQL1)
Do Until rsUserList.EOF
'This sets the value on the form
Forms![AdvanSec RptsFrm]![USER_ID] = Trim(rsUserList!USER_CODE)
'This query uses the value on the form
DoCmd.OpenQuery "SecRptEnabled_part3" 'Append query
rsUserList.MoveNext
Loop
GoSub PrintReport
Exit Function
Post the code that you're using, and post the SQL statement of the
query if it's not being built in the code.
--
Ken Snell
<MS ACCESS MVP>
I am trying to loop through code and pass a value to a field on a
form. The value in this field is then used as criteria in a query. The
form field is populated yet the query does not seem to recognize the
value on the form and returns "0" results.