Error handling (1 Viewer)

109bow

Registered User.
Local time
Today, 17:39
Joined
Oct 24, 2007
Messages
134
Hi All,
I have a linked table to an Excel file held on the company server. When I open a specific form, I have a delete query that deletes the contents of my table kmnow_tbl and then I use an Apppend query to update the table kmnow_tbl. The kmnow_tbl stores the current mileage for each train in our fleet. To do this I am using;
Private Sub Form_Open(Cancel As Integer)
DoCmd.SetWarnings False
On Error Resume Next
DoCmd.OpenQuery "kmnow_delete_qry"
On Error Resume Next
DoCmd.OpenQuery "kmnow_insert_qry"
On Error Resume Next
DoCmd.SetWarnings True
End Sub
The problem I have is that the data in table kmnow_tbl is deleted and if someone else has the source file open I cannot access the data in the Excel file and use the kmnow_insert_qry, so I have no data in the table to use.
I think what I need is to be able to check whether I can access the Excel file before the table kmnow_tbl is deleted, if access to the Excel file is not possible then do not run the delete query and append query.
As I have very, very limited concept of VBA I would be very grateful for some guidance.
Thanks
 

Users who are viewing this thread

Top Bottom