I have a couple of functions in VBA that run a series of queries in Access to download data from various sharepoints, manipulate it and then delete some data from SP, move data between SPs and finally upload new data. (it compiles data from various SP, and then because we have a 5k row limit on our SPs, moves historical versions of the result to archive SP, result is 1500 rows so archive has 3 old versions, and uploads new version). When it is run it quite often fails and my error handling reports that file is read only, I presume NW issues with SP connection and stops, but I cannot tell which step has failed. I need to restart but only from the step that failed so as to not lose a historical data set from the archive. In my shortest Fn I just inc a variable after each query and report this with the error so I can see. But my longest Fn has 100's of queries, and I really don't want to have to go through line by line and add a variable count. Is there a way of getting the error messge to include the query name that failed. My short function with variable included is below.
Function Export_to_sp()
On Error GoTo Export_to_sp_Err
Dim progress As Integer
DoCmd.SetWarnings False
DoCmd.OpenQuery "6-delete_C", acViewNormal, acEdit
Let Progress = 1
DoCmd.OpenQuery "6-rename_B_to_C", acViewNormal, acEdit
Let Progress = 2
DoCmd.OpenQuery "6-rename_A_to_B", acViewNormal, acEdit
Let Progress = 3
DoCmd.OpenQuery "6-rename_Active_to_A", acViewNormal, acEdit
Let Progress = 4
DoCmd.OpenQuery "6- export_to_Sp", acViewNormal, acEdit
Let Progress = 5
DoCmd.OpenQuery "6- move_A_to_backup", acViewNormal, acEdit
Let Progress = 6
DoCmd.OpenQuery "6-delete_A", acViewNormal, acEdit
Let Progress = 7
DoCmd.OpenQuery "upload_size_tracker_to_SP_new", acViewNormal, acEdit
Let Progress = 8
DoCmd.OpenQuery "Clear_old_for_current_SP"
Let Progress = 9
DoCmd.OpenQuery "3_open_op", acViewNormal, acEdit
Let Progress = 10
DoCmd.OpenQuery "export change log to new sp", acViewNormal, acEdit
Let Progress = 11
DoCmd.OpenQuery "clear_sp_table_size", acViewNormal, acEdit
Let Progress = 12
DoCmd.OpenQuery "count_local_std_res", acViewNormal, acEdit
Let Progress = 13
DoCmd.OpenQuery "count_local_res", acViewNormal, acEdit
Let Progress = 14
DoCmd.OpenQuery "count_sp_std_res", acViewNormal, acEdit
Let Progress = 15
DoCmd.OpenQuery "count_sp_ol_res", acViewNormal, acEdit
Let Progress = 16
DoCmd.OpenQuery "count_sp_backup_ol_result", acViewNormal, acEdit
Let Progress = 17
DoCmd.OpenQuery "count_audit_log", acViewNormal, acEdit
Let Progress = 18
DoCmd.OpenQuery "count_row_tracker", acViewNormal, acEdit
Let Progress = 19
DoCmd.OpenQuery "SP_export_sumary", acViewNormal, acEdit
Let Progress = 10
DoCmd.SetWarnings True
Export_to_sp_Exit:
Exit Function
Export_to_sp_Err:
MsgBox Error$
MsgBox Progress
Resume Export_to_sp_Exit
End Function