Private Sub ImportData()
On Error GoTo Err_ImportData
Dim stDocName As String
Dim PreviousDate As Date
PreviouseDate = Get_Previous_Business()
If ELookup("[WorkingDay]", "tblCalendar", "[CalDate] = " & "#" &
PreviouseDate & "#") = "N" Then
Exit Sub
End If
If DCount("*", "tblDaily", "[Activity_date] = " & "#" &
PreviouseDate & "#") = 0 And _
DCount("*", "SP APPEND DATA", "[Mydate] = " & "#" &
PreviouseDate & "#") > 0 Then
stDocName = "SP APPEND DATA"
DoCmd.OpenQuery stDocName, acNormal, acEdit
End If
Exit_ImportData:
Exit Sub
Err_ImportData:
Select Case Err
Case 0
Resume Exit_ImportData
Case Else
strErrMsg = strErrMsg & "Error #: " & Format$(Err.Number) &
vbCrLf
strErrMsg = strErrMsg & "Error Description: " & Err.Description
MsgBox strErrMsg, vbInformation, "Import Data"
Resume Exit_ImportData
End Select
End Sub
===== reply begins =====
Is that a copy/paste of your code? There appears to be a typo in a variable
name:
PreviouseDate = Get_Previous_Business()
"PreviousDate" or "PreviouseDate"? I would expect the code as written to
give you a compile error, unless you have the "Require Variable Declaration"
option turned off (which is a bad idea). However, I don't think that would
cause an error at run time, and certainly not error 0 (since that isn't an
error).
The error-handling in that code is set to ignore error# 0. I assume you put
that there in an attempt to stop the error message from appearing. Didit
work?
When you get the error message, is it coming from the MsgBox in the
error-handling code above -- you should be able to tell by the content,
formatting, and window title -- or is it coming from someplace else?
--
Dirk Goldgar, MS Access MVP
Access tips:
www.datagnostics.com/tips.html
(please reply to the newsgroup)