- Private Sub DatabaseUpdate_Click()
-
-
On Error GoTo Edit_Rates_Error
-
-
Dim strPath As String
-
Dim strFromFile As String
-
Dim strToFile As String
-
Dim db As DAO.Database
-
Dim rstFileList As DAO.Recordset
-
-
strPath = "G:\Unsecure-Share\New OEE System\"
-
-
strFromFile = strPath & _
-
"Data Tables\OEE Database v1.0 - Admin.accdb"
-
-
Set db = CurrentDb
-
Set rstFileList = db.OpenRecordset("DBUpdater", dbOpenDynaset)
-
With rstFileList
-
If Not (.BOF And .EOF) Then
-
rstFileList.MoveFirst
-
Do While Not .EOF
-
strToFile = strPath & rstFileList!SendTo
-
Call FileCopy(strFromFile, strToFile)
-
.MoveNext
-
Loop
-
End If
-
.Close
-
End With
-
db.Close
-
Set rstFileList = Nothing
-
Set db = Nothing
-
-
DoCmd.Quit
-
-
Edit_Rates_ExitHere:
-
Exit Sub
-
-
Edit_Rates_Error:
-
If Err.Number <> 70 Then
-
MsgBox Err.Description, vbExclamation, "Error #: " & Err.Number
-
End If
-
Resume Edit_Rates_ExitHere
-
Resume
-
-
End Sub
Instead of exiting the sub, is it possible to do a move next? I tried using .Movenext in several different areas of the code, but each time it would not compile. So I guess I'm missing something that will make this happen. This code works as it should but instead of stopping when it encounters error# 70 I would like it to go to the next record until complete.
Thanks for any help.
DJ,
You have the right idea here, with checking to see if the Error is a specific error. I assume that if it is Error 70, that you don't want the code to stop, but continue?
In that case, your EH sub would look like this: - Edit_Rates_Error:
-
If Err.Number = 70 Then
-
Resume Next
-
Else
-
MsgBox Err.Description, _
-
vbExclamation, _
-
"Error #: " & Err.Number
-
GoTo Edit_Rates_ExitHere
-
End If
-
End Sub
The Resume Next just picks up the code in the place that caused the error and moves to the next line. You must be careful with such a set-up, though, because some errors are caused because the code can't continue. But with prudent usage, this is a perfectly normal method of doing things.
Hope this hepps!
2 1093
DJ,
You have the right idea here, with checking to see if the Error is a specific error. I assume that if it is Error 70, that you don't want the code to stop, but continue?
In that case, your EH sub would look like this: - Edit_Rates_Error:
-
If Err.Number = 70 Then
-
Resume Next
-
Else
-
MsgBox Err.Description, _
-
vbExclamation, _
-
"Error #: " & Err.Number
-
GoTo Edit_Rates_ExitHere
-
End If
-
End Sub
The Resume Next just picks up the code in the place that caused the error and moves to the next line. You must be careful with such a set-up, though, because some errors are caused because the code can't continue. But with prudent usage, this is a perfectly normal method of doing things.
Hope this hepps!
Thanks Twinn
Error 70 is a permission error, meaning someone has it open, so if I get error 70, bypass and move on to the next one...
Ran through it and it works perfectly.
Thanks again.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: WSeeger |
last post by:
When creating a new class, is it encouraged to always include error
handling routines within your LET and GET procedures? It's seems that
most text books never seem to include much about error...
|
by: Christian Christmann |
last post by:
Hi,
assert and error handling can be used for similar purposes.
When should one use assert instead of try/catch and in which
cases the error handling is preferable?
I've read somewhere that...
|
by: Anthony England |
last post by:
Everyone knows that global variables get re-set in an mdb when an un-handled
error is encountered, but it seems that this also happens when the variable
is defined as private at form-level.
So...
|
by: Stefan Johansson |
last post by:
Hi all
I'am moving from Visual Foxpro and have a question
regarding "best practice" error handling in vb .net.
In VFP I have always used a "central" error handling
object in order to have a...
|
by: Al Williams |
last post by:
Hi,
I have error handling in place throughout my application. I also start the
application wrapped in error handling code to catch any unexpected
exceptions (i.e. exceptions that occur where I...
|
by: Metal Dave |
last post by:
I do not understand the error handling of SQL Server here. Any error in
bulk insert seems to halt the current T-SQL statement entirely, rendering
it impossible to log an error. The first statement...
|
by: Anthony England |
last post by:
(sorry for the likely repost, but it is still not showing on my news server
and after that much typing, I don't want to lose it)
I am considering general error handling routines and have...
|
by: pob |
last post by:
>From a form I have some code that calls 4 modules
frmMain
1 mod
2 mod
3 mod
4 mod
If mod 1 experiences an error the error handling works fine within mod
1 and writes out the error to a...
|
by: jeffc226 |
last post by:
I'm interested in an idiom for handling errors in functions without
using traditional nested ifs, because I think that can be very awkward
and difficult to maintain, when the number of error checks...
|
by: Lysander |
last post by:
Thought I would give something back with a few articles. This article is a bit of code to add error handling. When I have time, I want to write articles on multilingual databases, and Access...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |