W
Wild Bill
The following Form Load code is murdering me in A2000 SR-1 on W2000 SP4
- "msaccess.exe has generated errors and will be closed" (M.S.
developers, you bastards...)
I say it's the form load code because from a stable DB, I added the
code, did a compact (and the form reloads automatically following
compact) - then BOOM. COMMENTING THE FUNCTION CALL THEREIN seems to
prevent the crash (but I'm fuzzy there - I fear corruption).
A possible culprit is an unusual tactic where I used a Table link within
the same database (it was tricky to even come up with such) - it is
called LinkAlias below. Another worry is the use of DAO360 - I did try
regsvr32 to no avail. jetcomp.exe didn't help (didn't bark either).
Any tips appreciated.
Private Sub Form_Load()
Dim i As Integer, sStr As String, sStrDefault As String, iListCount As
Integer
Dim obj As AccessObject, dbs As Object, iSelectThisOne As Integer
sStrDefault = Mid(lstbExpTable.DefaultValue, 2,
Len(lstbExpTable.DefaultValue) - 2)
sStr = """"
Set dbs = Application.CurrentData
iListCount = 0
For Each obj In dbs.AllTables ' Search for open AccessObject objects
in AllTables collection.
If Left(obj.Name, 7) = "tblmort" Then
If iListCount > 0 Then sStr = sStr & """" & ";" & """"
sStr = sStr & obj.Name
iListCount = iListCount + 1
If obj.Name = sStrDefault Then
iSelectThisOne=iListCount-1 'only way I know to identify
selected listbox item
End If
End If
Next obj
Set dbs = Nothing
Me.lstbExpTable.RowSource = sStr & """"
lstbExpTable.Selected(iSelectThisOne) = True
Call SetNewExpectedTable
lstRptNames.Selected(0) = True
End Sub
Private Sub SetNewExpectedTable()
Dim rs As DAO.Recordset, sStr As String
On Error Resume Next
CurrentDb.TableDefs.Delete "LinkAlias"
On Error GoTo 0
If Left(lstbExpTable, 1) = """" Then
sStr = Mid(lstbExpTable, 2, Len(lstbExpTable) - 2)
Else
sStr = lstbExpTable 'having trouble w/ hard double quotes in strings
End If
Set rs = CurrentDb.OpenRecordset(sStr)
rs.MoveFirst
DoCmd.TransferDatabase acLink,"Microsoft Access",CurrentDb.Name,
acTable, sStr,"LinkAlias"
rs.Close
Set rs = Nothing
End Sub
- "msaccess.exe has generated errors and will be closed" (M.S.
developers, you bastards...)
I say it's the form load code because from a stable DB, I added the
code, did a compact (and the form reloads automatically following
compact) - then BOOM. COMMENTING THE FUNCTION CALL THEREIN seems to
prevent the crash (but I'm fuzzy there - I fear corruption).
A possible culprit is an unusual tactic where I used a Table link within
the same database (it was tricky to even come up with such) - it is
called LinkAlias below. Another worry is the use of DAO360 - I did try
regsvr32 to no avail. jetcomp.exe didn't help (didn't bark either).
Any tips appreciated.
Private Sub Form_Load()
Dim i As Integer, sStr As String, sStrDefault As String, iListCount As
Integer
Dim obj As AccessObject, dbs As Object, iSelectThisOne As Integer
sStrDefault = Mid(lstbExpTable.DefaultValue, 2,
Len(lstbExpTable.DefaultValue) - 2)
sStr = """"
Set dbs = Application.CurrentData
iListCount = 0
For Each obj In dbs.AllTables ' Search for open AccessObject objects
in AllTables collection.
If Left(obj.Name, 7) = "tblmort" Then
If iListCount > 0 Then sStr = sStr & """" & ";" & """"
sStr = sStr & obj.Name
iListCount = iListCount + 1
If obj.Name = sStrDefault Then
iSelectThisOne=iListCount-1 'only way I know to identify
selected listbox item
End If
End If
Next obj
Set dbs = Nothing
Me.lstbExpTable.RowSource = sStr & """"
lstbExpTable.Selected(iSelectThisOne) = True
Call SetNewExpectedTable
lstRptNames.Selected(0) = True
End Sub
Private Sub SetNewExpectedTable()
Dim rs As DAO.Recordset, sStr As String
On Error Resume Next
CurrentDb.TableDefs.Delete "LinkAlias"
On Error GoTo 0
If Left(lstbExpTable, 1) = """" Then
sStr = Mid(lstbExpTable, 2, Len(lstbExpTable) - 2)
Else
sStr = lstbExpTable 'having trouble w/ hard double quotes in strings
End If
Set rs = CurrentDb.OpenRecordset(sStr)
rs.MoveFirst
DoCmd.TransferDatabase acLink,"Microsoft Access",CurrentDb.Name,
acTable, sStr,"LinkAlias"
rs.Close
Set rs = Nothing
End Sub