I have a piece of vba code that is running successfully, however, when I was asked to exclude certain records the code aborts. I've tried several ideas including turning the query that is the basis for the exclusion into a table (via make table query) and joined with the table rather than the query, with no luck. I have been able to identify where the code aborts, but haven't figured out what else to try.
When I step through the code, it gets as far as .Edit, after that, when I press F8 it drops out of the code. It does not go to the line following .Edit:
I can open the queries individually and they run fine.
The queries that do not abort when run in vba are:
This is for recordset "rs"
This is for recordset "rsText"
These are rs and rsText respectively with the additional table/criteria in red. The revised queries do not contain additional display cols, only an additional WHERE statement.
This is for recordset "rsText"
If further code is needed, please let me know.
When I step through the code, it gets as far as .Edit, after that, when I press F8 it drops out of the code. It does not go to the line following .Edit:
Code:
rs.FindFirst "ncessch = '" & rsText!ncessch & "'"
If Not rs.NoMatch Then
.Edit
rs!type = rsText.Fields(6)
I can open the queries individually and they run fine.
The queries that do not abort when run in vba are:
This is for recordset "rs"
Code:
SELECT tbl_schools_xyr.unique_schid, tbl_schools_xyr.ncessch, tbl_schools_xyr.state,
tbl_schools_xyr.seasch, tbl_schools_xyr.stid, tbl_schools_xyr.schoolname, tbl_schools_xyr.type,
tbl_schools_xyr.operating_status, tbl_schools_xyr.locale, tbl_schools_xyr.leaid, tbl_schools_xyr.gr_lo,
tbl_schools_xyr.gr_hi, tbl_schools_xyr.level, tbl_schools_xyr.ccd_charter_status,
tbl_schools_xyr.num_students, tbl_schools_xyr.date_edited
FROM tbl_schools_xyr
WHERE left(tbl_schools_xyr.sch_yr,4) = '2005' AND tbl_schools_xyr.state = 'NJ';
This is for recordset "rsText"
Code:
SELECT tbl_schools_xyr.unique_schid, tbl_schools_xyr.ncessch, tbl_schools_xyr.state,
simplified.seasch05, simplified.stid05, simplified.schnam05, simplified.type05,
simplified.status05, simplified.ulocal05, simplified.leaid05, simplified.gslo05,
simplified.gshi05, simplified.level05, simplified.chartr05, simplified.member05,
tbl_schools_xyr.date_edited
FROM tbl_schools_xyr INNER JOIN Ccd_05_appended_simplified AS simplified
ON tbl_schools_xyr.ncessch = simplified.ncessch
WHERE left(tbl_schools_xyr.sch_yr,4) = '2005' AND tbl_schools_xyr.state = 'NJ';
These are rs and rsText respectively with the additional table/criteria in red. The revised queries do not contain additional display cols, only an additional WHERE statement.
Code:
SELECT tbl_schools_xyr.unique_schid, tbl_schools_xyr.ncessch, tbl_schools_xyr.state,
tbl_schools_xyr.seasch, tbl_schools_xyr.stid, tbl_schools_xyr.schoolname, tbl_schools_xyr.type,
tbl_schools_xyr.operating_status, tbl_schools_xyr.locale, tbl_schools_xyr.leaid, tbl_schools_xyr.gr_lo,
tbl_schools_xyr.gr_hi, tbl_schools_xyr.level, tbl_schools_xyr.ccd_charter_status, tbl_schools_xyr.num_students,
tbl_schools_xyr.date_edited
FROM tbl_schools_xyr [COLOR=#EF2929]LEFT JOIN tblSkip
ON (tbl_schools_xyr.sch_yr = qrySkip.sch_yr) AND (tbl_schools_xyr.ncessch = tblSkip.ncessch)[/color]
WHERE left(tbl_schools_xyr.sch_yr,4) = '2005' AND tbl_schools_xyr.state = 'NJ' [COLOR=#EF2929]AND tblSkip.ncessch is not null[/color];
This is for recordset "rsText"
Code:
SELECT tbl_schools_xyr.unique_schid, tbl_schools_xyr.ncessch, tbl_schools_xyr.state,
simplified.seasch05, simplified.stid05, simplified.schnam05, simplified.type05, simplified.status05,
simplified.ulocal05, simplified.leaid05, simplified.gslo05, simplified.gshi05, simplified.level05,
simplified.chartr05, simplified.member05, tbl_schools_xyr.date_edited
FROM (tbl_schools_xyr INNER JOIN Ccd_05_appended_simplified AS simplified
ON tbl_schools_xyr.ncessch = simplified.ncessch) [COLOR=#EF2929]LEFT JOIN tblSkip
ON (tbl_schools_xyr.sch_yr = tblSkip.sch_yr) AND (tbl_schools_xyr.ncessch = tblSkip.ncessch)[/color]
WHERE left(tbl_schools_xyr.sch_yr,4) = '2005' AND tbl_schools_xyr.state = 'NJ' [COLOR=#EF2929]AND tblSkip.ncessch is not null[/color];
If further code is needed, please let me know.