G
Guest
strSQLc = "Select * From [WorkSpaceDoctorsOrders]"
'next statement generates error "item not found in this collection"
Set rsc = CurrentDb.Recordsets(strSQLc)
Following are excerpts of my code, why is WorkSpaceDoctorsOrders suddenly
not found, when I've used it throughout this procedure, and how can I fix it?
I have properly declared strsqlc and rsc and the beginning of this code. I
am using these vars to open another query to loop through, and it is closed
prior to setting up this statement as shown in code below.
'several statements preceding this section works fine...
'this code is to delete data from a working table and it works fine
strSQLwsDO = "DELETE * From [WorkSpaceDoctorsOrders]"
DoCmd.RunSQL (strSQLwsDO)
.... more code works fine
do until rsc.eof
'... more code works fine to determine following sql vars
strSQLi = "Insert into WorkSpaceDoctorsOrders("
strSQLi = strSQLi & "[DO-FK Cert Period id], [DO-FK Visit Code], "
strSQLi = strSQLi & "[DO Occurrences], [DO-FK Type of Visit], "
strSQLi = strSQLi & "[DO Number Of Weeks], [DO Date Start Week]) "
strSQLi = strSQLi & "Values ("
strSQLi = strSQLi & stCertPeriod & ", '" & stVisitCode & "', "
strSQLi = strSQLi & stOccurrences & ",'ST',"
strSQLi = strSQLi & stWeeks & ", #" & maxDateST & "#)"
DoCmd.RunSQL (strSQLi)
rsc.MoveNext
Loop
rsc.Close
Set rsc = Nothing
Set rsp = Nothing
.... all the code above works fine
.... then when I get here I have problems
strSQLc = "Select * From [WorkSpaceDoctorsOrders]"
'the next statement generates the error item not found in this collection
Set rsc = CurrentDb.Recordsets(strSQLc)
'next statement generates error "item not found in this collection"
Set rsc = CurrentDb.Recordsets(strSQLc)
Following are excerpts of my code, why is WorkSpaceDoctorsOrders suddenly
not found, when I've used it throughout this procedure, and how can I fix it?
I have properly declared strsqlc and rsc and the beginning of this code. I
am using these vars to open another query to loop through, and it is closed
prior to setting up this statement as shown in code below.
'several statements preceding this section works fine...
'this code is to delete data from a working table and it works fine
strSQLwsDO = "DELETE * From [WorkSpaceDoctorsOrders]"
DoCmd.RunSQL (strSQLwsDO)
.... more code works fine
do until rsc.eof
'... more code works fine to determine following sql vars
strSQLi = "Insert into WorkSpaceDoctorsOrders("
strSQLi = strSQLi & "[DO-FK Cert Period id], [DO-FK Visit Code], "
strSQLi = strSQLi & "[DO Occurrences], [DO-FK Type of Visit], "
strSQLi = strSQLi & "[DO Number Of Weeks], [DO Date Start Week]) "
strSQLi = strSQLi & "Values ("
strSQLi = strSQLi & stCertPeriod & ", '" & stVisitCode & "', "
strSQLi = strSQLi & stOccurrences & ",'ST',"
strSQLi = strSQLi & stWeeks & ", #" & maxDateST & "#)"
DoCmd.RunSQL (strSQLi)
rsc.MoveNext
Loop
rsc.Close
Set rsc = Nothing
Set rsp = Nothing
.... all the code above works fine
.... then when I get here I have problems
strSQLc = "Select * From [WorkSpaceDoctorsOrders]"
'the next statement generates the error item not found in this collection
Set rsc = CurrentDb.Recordsets(strSQLc)