Question : How Do I Deternine the Cause of a Faulting Application (msaccess)/module (msvcrt.dll)?

Problem/Question: How do I determine the cause of the error described below?

Error in Event Viewer (Application):
Faulting application msaccess.exe, version 11.0.6566.0, stamp 42cdb33e, faulting module msvcrt.dll, version 7.0.2600.5512, stamp 4802a188, debug? 0, fault address 0x000372e3.

Scenario:
Scheduled task runs nightly at 11pm.  Invokes a batch job that invokes a macro (from Access mdb) that runs an Import function written in Visual Basic.  VB Code reads from ASCII delimited text file and updates SQL Server table.  Nothing else runs at this time.  The job is scheduled to kick off even if not logged in.  Has been running as is for years.  According to the System Info, it had a similar glitch 5 times in 2007 (I wasn't at this job yet).  It has recently encountered this error on 11/25/08, 12/23/08, and 1/1/09.  Nothing appears to conflict (no anti-virus software, backups or updates run at this time).  Besides critical security updates from MS, nothing on this system has changed in years.  The error appears to occur immediately when Access is invoked.

Details:
Backend DB: MS SQL Server 2000
DB Server: Windows Server 2000
Front End DB: MS Access 2003 sp3 (mdb - not compiled db) on a
Windows XP Pro 2002 server
Source: MS Visual Basic (main function included in "Code" section.

Files:
msaccess.exe File: 7/7/2005 6502kb
msvcrt.dll: 4/13/08 335kb in system32 directory  (other file names exist msvcrt20.dll, msvcrt40.dll) and other msvcrt.dll files exist, but the msvcrt.dll of 4/13/08 is the only one in a windows directory.
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
Option Compare Database
Option Explicit
 
Function ImportSAAChanges()
Dim Ary() As String
Dim stTmp As String
Dim rs As dao.Recordset
Dim db As Database
Dim PathName As String
Dim StatusFilePathName As String
Dim StatusFilePathNametest As String
Dim TableName As String
Dim stTemp As String
Dim fileWpath As String
Dim IntRecordsProcessed As Integer
 
    'Location of export file from the Sergeant At Arms Database
    PathName = "Z:\SAA_Export1.txt"
    'PathName = "C:\MIKE\ACCESS\OUTPUT\SAA_Export.txt"
    'StatusFilePathName = "C:\MIKE\ACCESS\OUTPUT\HISTORY\SAA_Export-" & Date$ & ".txt"
    StatusFilePathName = "Z:\HISTORY\SAA_Export-" & Date$ & ".txt"
    StatusFilePathNametest = "Z:\HISTORY\SAA_Export-Test-" & Date$ & ".txt"
    TableName = "dbo_Employee"
    IntRecordsProcessed = 0
    
    'Test that the file exists
    If Len(Dir(PathName)) > 0 Then
        'Determine if the employee already exists through the ImageId field
        stTemp = "SELECT * FROM " & TableName
        Set db = CurrentDb()
        Set rs = db.OpenRecordset(TableName, , dbOpenDynamic)
        
        Open PathName For Input As #1
        
        While Not EOF(1)
            On Error Resume Next
            'test output
            Open StatusFilePathNametest For Output As #3
        
            'Read a single line (dump the end of line marker)
            Line Input #1, stTmp
            IntRecordsProcessed = IntRecordsProcessed + 1
            
            'Split the readLine on Comma
            Ary = Split(stTmp, "|")
            
            'Look for a matching ImageID
            rs.FindFirst "ImageId='" & Ary(7) & "'"
            'If there IS a MATCHING ImageID
            If Not rs.NoMatch Then
                'ImageID DOES exist
                If Ary(11) = "TERMINATED" Then 'DELETE the record.
                    rs.Delete
                    rs.Requery
                    Write #3, "Testing Import from SAA, " & IntRecordsProcessed & " records updated"
                ElseIf CDbl(rs!SerialNo) <= CDbl(Ary(0)) Then 'It's an update
                    rs.Edit
                    rs!SerialNo = Ary(0)
                    rs!CardNo = Ary(1)
                    rs!BadgeStatus = Ary(2)
                    'rs!SSN = IIf(Ary(3) = "", 0, Ary(3))
                    rs!SSN = Ary(3)
                    rs!LastName = Ary(4)
                    rs!FirstName = Ary(5)
                    rs!Middle = Ary(6)
                    'rs!ImageID = Ary(7)
                    rs!ChangeDate = Ary(8)
                    rs!VendorIndex = Ary(9)
                    rs!SponsorIndex = Ary(10)
                    rs!PersonnelStatus = Ary(11)
                    rs.Update
                    rs.Requery
                    Write #3, "Testing Import from SAA, " & IntRecordsProcessed & " records updated"
                End If
            Else 'ImageID DOES NOT exist,
                If Ary(11) <> "TERMINATED" Then
                    rs.AddNew
                    rs!SerialNo = Ary(0)
                    rs!CardNo = Ary(1)
                    rs!EmployeeID = NextEmpID()  'Call NextEmpID function
                    rs!BadgeStatus = Ary(2)
                    'rs!SSN = IIf(Ary(3) = "", 0, Ary(3))
                    rs!SSN = Ary(3)
                    rs!LastName = Ary(4)
                    rs!FirstName = Ary(5)
                    rs!Middle = Ary(6)
                    rs!ImageID = Ary(7)
                    rs!ChangeDate = Ary(8)
                    rs!VendorIndex = Ary(9)
                    rs!SponsorIndex = Ary(10)
                    rs!PersonnelStatus = Ary(11)
                    rs.Update
                    rs.Requery
                    Write #3, "Testing Import from SAA, " & IntRecordsProcessed & " records updated"
                End If
            End If
        Wend
        'Write stats to HISTORY File
        'Create the File
        Open StatusFilePathName For Output As #2
        Write #2, "Finished Import from SAA, " & IntRecordsProcessed & " records updated"
        Close #2
        Close #3
        Close #1
        rs.Close
        Set rs = Nothing
        Set db = Nothing
    Else 'File does not exist, output blank Status
        'Create the File
        Open StatusFilePathName For Output As #2
        Write #2, "No Export from SAA found, 0 records updated"
        Close #2
    End If 'File Exists
    
End Function
 
 
Function ImportSAATextFile()
Dim Ary() As String
Dim stTmp As String
Dim rs As dao.Recordset
Dim bFirstNameMatched As Boolean
Dim I As Long
Dim db As Database
Dim PathName As String
Dim TableName As String
Dim stTemp As String
Dim strFirstName As String
 
    Set db = CurrentDb()
    'Location of export file from the Sergeant At Arms Database
    'PathName = "Z:\SAA_EXPORT.txt"
    PathName = "C:\MIKE\ACCESS\OUTPUT\SAA_Export_REM.txt"
    TableName = "dbo_Employee"
    
    'Determine if the employee already exists through the CardNo field
    'stTemp = "SELECT CardNo FROM " & TableName
    stTemp = "SELECT * FROM " & TableName
    Set rs = db.OpenRecordset(TableName, , dbOpenDynamic)
    Open PathName For Input As #1
    
    While Not EOF(1)
        'Read a single line (dump the end of line marker)
        Line Input #1, stTmp
        
        'Split the readLine on Comma
        Ary = Split(stTmp, "|")
        '****If there is not ten fields, skip the record.****
        If Ary(2) = "ACTIVE" Then 'Update the record.
            rs.FindFirst "CardNo='" & Ary(1) & "'"
            'If there is a Matching CardNo
            If Not rs.NoMatch Then
                    'CardNo DOES exist
                    rs.Edit
                    rs!SerialNo = Ary(0)
                    rs!BadgeStatus = Ary(2)
                    'rs!SSN = IIf(Ary(3) = "", 0, Ary(3))
                    rs!SSN = Ary(3)
                    rs!LastName = Ary(4)
                    rs!FirstName = Ary(5)
                    rs!Middle = Ary(6)
                    rs!ImageID = Ary(7)
                    rs!ChangeDate = Ary(8)
                    rs!VendorIndex = Ary(9)
                    rs!SponsorIndex = Ary(10)
                    rs!PersonnelStatus = Ary(11)
                    rs.Update
            Else 'CardNo DOES NOT exist,
                'rs.FindFirst "LastName=" & Ary(4) & "'"
                rs.FindFirst "LastName=" & Chr$(34) & Ary(4) & Chr$(34)
                If Not rs.NoMatch Then 'LASTNAME matches
                    If rs!FirstName = Ary(5) Then
                        'Last and First names match the TEXT file record, UPDATE
                        rs.Edit
                        rs!SerialNo = Ary(0)
                        rs!CardNo = Ary(1)
                        rs!BadgeStatus = Ary(2)
                        'rs!SSN = IIf(Ary(3) = "", 0, Ary(3))
                        rs!SSN = Ary(3)
                        rs!LastName = Ary(4)
                        rs!FirstName = Ary(5)
                        rs!Middle = Ary(6)
                        rs!ImageID = Ary(7)
                        rs!ChangeDate = Ary(8)
                        rs!VendorIndex = Ary(9)
                        rs!SponsorIndex = Ary(10)
                        rs!PersonnelStatus = Ary(11)
                        rs.Update
                    Else 'FirstName did not match, find record that does.
                        bFirstNameMatched = False
                        Do While (Not bFirstNameMatched)
                            rs.FindNext "LastName=" & Chr$(34) & Ary(4) & Chr$(34)
                            If Not rs.NoMatch Then 'There is another person with that last name.
                                If rs!FirstName = Ary(5) Then
                                    'FirstName matches, update record
                                    bFirstNameMatched = True
                                    rs.Edit
                                    rs!SerialNo = Ary(0)
                                    rs!CardNo = Ary(1)
                                    rs!BadgeStatus = Ary(2)
                                    'rs!SSN = IIf(Ary(3) = "", 0, Ary(3))
                                    rs!SSN = Ary(3)
                                    rs!LastName = Ary(4)
                                    rs!FirstName = Ary(5)
                                    rs!Middle = Ary(6)
                                    rs!ImageID = Ary(7)
                                    rs!ChangeDate = Ary(8)
                                    rs!VendorIndex = Ary(9)
                                    rs!SponsorIndex = Ary(10)
                                    rs!PersonnelStatus = Ary(11)
                                    rs.Update
                                End If
                            Else 'There is no one else with that last name, ADD Record
                                'EDIT record.
                                bFirstNameMatched = True
                                rs.AddNew
                                rs!SerialNo = Ary(0)
                                rs!CardNo = Ary(1)
                                'Call NextEmpID function
                                rs!EmployeeID = NextEmpID()
                                rs!BadgeStatus = Ary(2)
                                'rs!SSN = IIf(Ary(3) = "", 0, Ary(3))
                                rs!SSN = Ary(3)
                                rs!LastName = Ary(4)
                                rs!FirstName = Ary(5)
                                rs!Middle = Ary(6)
                                rs!ImageID = Ary(7)
                                rs!ChangeDate = Ary(8)
                                rs!VendorIndex = Ary(9)
                                rs!SponsorIndex = Ary(10)
                                rs!PersonnelStatus = Ary(11)
                                rs.Update
                            End If
                        Loop
                    End If
                Else 'There was no matching LastName, Add New Employee Record
                    rs.AddNew
                    rs!SerialNo = Ary(0)
                    rs!CardNo = Ary(1)
                    rs!EmployeeID = NextEmpID()  'Call NextEmpID function
                    rs!BadgeStatus = Ary(2)
                    'rs!SSN = IIf(Ary(3) = "", 0, Ary(3))
                    rs!SSN = Ary(3)
                    rs!LastName = Ary(4)
                    rs!FirstName = Ary(5)
                    rs!Middle = Ary(6)
                    rs!ImageID = Ary(7)
                    rs!ChangeDate = Ary(8)
                    rs!VendorIndex = Ary(9)
                    rs!SponsorIndex = Ary(10)
                    rs!PersonnelStatus = Ary(11)
                    rs.Update
                End If
            End If
        End If
    Wend
    Close #1
    rs.Close
    Set rs = Nothing
    Set db = Nothing
    
End Function
 
Private Function NextEmpID() As Long
Dim stTmp As String
Dim rsEmpID As dao.Recordset
Dim dbEmpId As Database
Dim PathName As String
Dim TableName As String
 
Set dbEmpId = CurrentDb()
TableName = "dbo_Employee"
stTmp = "Select Max([EmployeeID]) as MaxEmpID from " & TableName & "'"
 
Set rsEmpID = dbEmpId.OpenRecordset(stTmp, , dbOpenSnapshot)
NextEmpID = rsEmpID!MaxEmpID + 1
 
rsEmpID.Close
Set rsEmpID = Nothing
Set dbEmpId = Nothing
 
End Function
Open in New Window Select All

Answer : How Do I Deternine the Cause of a Faulting Application (msaccess)/module (msvcrt.dll)?

The access faults seemed to coincide with at least one run time error that sometimes displayed (the server  sometimes displayed no indication of error - hung screen, other times a run time, and other times a general fault error).  Correcting run time errors 52 and 9 appear to have fixed the problems.  Detailed descriptions:
Run time error 52 was due to connectivity issues.  Causes included the replication program dropping the odbc alias due to comm. errors at the remote replication site.  We updated the DNS manually to get the alias info back into the DNS servers.  Later the network problems were fixed as well.  In addition, we modified tcpip setting.  
Run time error 9 is a subscripts bounds overflow.  A data error in the ASCII file caused one of the elements not to exist (the data line was terminated prematurely with a CR).  This element was used as a subscript.
Although the scheduled task is set to be invoked even if not logged in, it seems to require remaining logged in to the db server - otherwise these abnormal program terminations occurred.

Random Solutions  
 
programming4us programming4us