S
Sacapuce
Here are a few problems I have come accross while trying to produce a ACCDR
(runtime) version of an ACCDE database with some solutions:
1- if you use the docmd.rename command to change a table name, it works in
the ACCDE version but somehow NOT in the ACCCDR runtime version. It just
seems to ignore it. Instead, I had to use a piece of code to do the rename:
Public Function RenameTable(ByVal TableName As String, ByVal ToName As
String) As Boolean
On Error GoTo Error_Handler
Dim db As Database
Dim tbldef As TableDefs
Dim tblTable As TableDef
'checks whether a table exists
Set db = CurrentDb()
Set tbldefs = db.TableDefs
RenameTable = False
For Each tblTable In tbldefs
If tblTable.Name = TableName Then
tblTable.Name = ToName
RenameTable = True
End If
Next
tbldefs.Refresh
db.Close
Set tbldef = Nothing
Set db = Nothing
Exit_Procedure:
On Error Resume Next
Exit Function
Error_Handler:
DisplayUnexpectedError Err.Number, Err.Description
Resume Exit_Procedure
Resume
End Function
2- Before producing an ACCDE from and ACCDB, make sure to use the
Debug/Compile action in the VBE menu bar and correct all errors in the code
as Access will not create an ACCDE with errors in the code.
3- in the same vein as point 1, the command IsObject() for checking the
existence of a table (or other) object will return an error message when no
object can be found (it should return 'false' according to the help file). A
way around it is to account for the error message in a public function (in
this case to check for the existence of a particular table):
Public Function CheckTable(ByVal TableName As String) As Boolean
On Error GoTo Error_Handler
Dim db As Database
Dim tbldef As TableDefs
'checks whether a table exists
Set db = CurrentDb()
If IsObject(db.TableDefs(TableName)) = True Then CheckTable = True
db.Close
Set db = Nothing
Exit_Procedure:
On Error Resume Next
DoCmd.Hourglass False
DoCmd.SetWarnings True
Exit Function
Error_Handler:
If Err.Number = 3265 Then 'it is not there
CheckTable = False
Else
DisplayUnexpectedError Err.Number, Err.Description
End If
Resume Exit_Procedure
Resume
End Function
It's all fun!
(runtime) version of an ACCDE database with some solutions:
1- if you use the docmd.rename command to change a table name, it works in
the ACCDE version but somehow NOT in the ACCCDR runtime version. It just
seems to ignore it. Instead, I had to use a piece of code to do the rename:
Public Function RenameTable(ByVal TableName As String, ByVal ToName As
String) As Boolean
On Error GoTo Error_Handler
Dim db As Database
Dim tbldef As TableDefs
Dim tblTable As TableDef
'checks whether a table exists
Set db = CurrentDb()
Set tbldefs = db.TableDefs
RenameTable = False
For Each tblTable In tbldefs
If tblTable.Name = TableName Then
tblTable.Name = ToName
RenameTable = True
End If
Next
tbldefs.Refresh
db.Close
Set tbldef = Nothing
Set db = Nothing
Exit_Procedure:
On Error Resume Next
Exit Function
Error_Handler:
DisplayUnexpectedError Err.Number, Err.Description
Resume Exit_Procedure
Resume
End Function
2- Before producing an ACCDE from and ACCDB, make sure to use the
Debug/Compile action in the VBE menu bar and correct all errors in the code
as Access will not create an ACCDE with errors in the code.
3- in the same vein as point 1, the command IsObject() for checking the
existence of a table (or other) object will return an error message when no
object can be found (it should return 'false' according to the help file). A
way around it is to account for the error message in a public function (in
this case to check for the existence of a particular table):
Public Function CheckTable(ByVal TableName As String) As Boolean
On Error GoTo Error_Handler
Dim db As Database
Dim tbldef As TableDefs
'checks whether a table exists
Set db = CurrentDb()
If IsObject(db.TableDefs(TableName)) = True Then CheckTable = True
db.Close
Set db = Nothing
Exit_Procedure:
On Error Resume Next
DoCmd.Hourglass False
DoCmd.SetWarnings True
Exit Function
Error_Handler:
If Err.Number = 3265 Then 'it is not there
CheckTable = False
Else
DisplayUnexpectedError Err.Number, Err.Description
End If
Resume Exit_Procedure
Resume
End Function
It's all fun!