G
Guest
Hi
first i appologize for reposting this. i posted this in the excel section,
and that was not my intention.
here is my question:
How do i query an open recordset. currently i have a saved query and then i
have a sql statement in VBA which queries the query. I would like to run the
first query in VBA and then have the second SQL statement query the first
recordset. is this possible??
the reason i want this is first of all, i am having problems with the
parameters. secondly, it is neater for me to have this way.
i will post the query and the recordset SQL
thanks,
sam
this is the query (saved as PPAllFctsRetentionQry):
Code:
SELECT DISTINCT PPYearlyIndex.PgpPayGroup, PPYearlyIndex.PgpPeriodStartDate,
PPYearlyIndex.PgpPeriodEndDate
FROM PPYearlyIndex
WHERE (((PPYearlyIndex.PayperiodIndex) Between
[Forms]![RetentionAllFrm]![cboPayperiodIndexStart] And
[Forms]![RetentionAllFrm]![cboPayperiodIndexEnd]) AND
((PPYearlyIndex.PayperiodYear) Between
[Forms]![RetentionAllFrm]![cboPayperiodYearStart] And
[Forms]![RetentionAllFrm]![cboPayperiodYearEnd]));
now i have this SQL statment in my VBA code which i would i refer to as my
second query:
Code:
strSQL = "SELECT PPAllFctsRetentionQry.PgpPayGroup,
Min(PPAllFctsRetentionQry.PgpPeriodStartDate) AS FirstStartDate,
Max(PPAllFctsRetentionQry.PgpPeriodStartDate) AS LastStartDate,
Min(PPAllFctsRetentionQry.PgpPeriodEndDate) AS FirstEndDate,
Max(PPAllFctsRetentionQry.PgpPeriodEndDate) AS LastEndDate " & _
" FROM PPAllFctsRetentionQry GROUP BY
PPAllFctsRetentionQry.PgpPayGroup;"
first i appologize for reposting this. i posted this in the excel section,
and that was not my intention.
here is my question:
How do i query an open recordset. currently i have a saved query and then i
have a sql statement in VBA which queries the query. I would like to run the
first query in VBA and then have the second SQL statement query the first
recordset. is this possible??
the reason i want this is first of all, i am having problems with the
parameters. secondly, it is neater for me to have this way.
i will post the query and the recordset SQL
thanks,
sam
this is the query (saved as PPAllFctsRetentionQry):
Code:
SELECT DISTINCT PPYearlyIndex.PgpPayGroup, PPYearlyIndex.PgpPeriodStartDate,
PPYearlyIndex.PgpPeriodEndDate
FROM PPYearlyIndex
WHERE (((PPYearlyIndex.PayperiodIndex) Between
[Forms]![RetentionAllFrm]![cboPayperiodIndexStart] And
[Forms]![RetentionAllFrm]![cboPayperiodIndexEnd]) AND
((PPYearlyIndex.PayperiodYear) Between
[Forms]![RetentionAllFrm]![cboPayperiodYearStart] And
[Forms]![RetentionAllFrm]![cboPayperiodYearEnd]));
now i have this SQL statment in my VBA code which i would i refer to as my
second query:
Code:
strSQL = "SELECT PPAllFctsRetentionQry.PgpPayGroup,
Min(PPAllFctsRetentionQry.PgpPeriodStartDate) AS FirstStartDate,
Max(PPAllFctsRetentionQry.PgpPeriodStartDate) AS LastStartDate,
Min(PPAllFctsRetentionQry.PgpPeriodEndDate) AS FirstEndDate,
Max(PPAllFctsRetentionQry.PgpPeriodEndDate) AS LastEndDate " & _
" FROM PPAllFctsRetentionQry GROUP BY
PPAllFctsRetentionQry.PgpPayGroup;"