Solution to Activity 10.1
The solution to this activity is as follows:
- Make the necessary code changes to each SQL block.
- For the SQL 2 block, the existing
SQL
statement works in Workbench, so no changes are required. Keep the code as it is:SQL = "SELECT Count(GenderStats.ID) AS RecCount FROM GenderStats;"
- On the second line, the
Set RS =
statement is not required at this location, so comment it out:'Set RS = CurrentDb.OpenRecordset(SQL, dbOpenDynaset)
- Call the
CreatePassThrough
function by passing in the SQL statement and the name for the new passthrough query,GENCount
. PassTrue
, which indicates that the passthrough will return a value, andFalse
because we do not want to delete the old passthrough query first; it will overwrite it:Call CreatePassThrough(SQL, "GENCount", True, False)
- Place
Set RS =
after the query that will create it and change the recordset source toGENCount
:Set RS = CurrentDb.OpenRecordset("GENCount"...