sql - Operation is not allowed when object is closed VBA -


my code fails above error when reaches 4th line of following code. i've used same format earlier in program , works fine. if more code needed resolve error i'd happy post. thanks.

with rstip19 .activeconnection = cntip .open "exec usp_service_data_query_qa" thisworkbook.sheets("service_data").range("a" & rows.count).end(xlup).offset(1, 0).copyfromrecordset rstip19 .close end 

what purpose of exec? should test .bof or .eof.

with rstip19      .activeconnection = cntip     .open "usp_service_data_query_qa"     if not .bof or .eof         thisworkbook.sheets("service_data").range("a" & rows.count).end(xlup).offset(1, 0).copyfromrecordset rstip19     end if      .close  end 

Comments