Heinz-Josef Bomanns
Posts: 206
Joined: 2008-02-28
|
Hi,
ADX latest version, Access 2002-2010: A database is set to compress automatically on exit. After running a dialog from the add-in and leaving the database i get an error 'Database is exclusivelly opened by user X on machine Y...' and the database won't compress. The dialog accesses the current database to fill a combobox with the names of tables like this:
Dim db As dao.Database = Nothing, tds As dao.TableDefs = Nothing, td As dao.TableDef = Nothing
db = AddinModule.CurrentInstance.HostApplication.CurrentDB() 'Access Application
tds = db.TableDefs
With clAccTables
.Items.Clear()
.Items.Add("<Choose table>")
For Each td In tds
If Not td.Name.StartsWith("MSys") And Not td.Name.StartsWith("USys") Then
.Items.Add(td.Name)
End If
Next 'td
.SelectedIndex = 0
End With 'clAccTables
Marshal.ReleaseComObject(td) : td = Nothing
Marshal.ReleaseComObject(tds) : tds = Nothing
Marshal.ReleaseComObject(db) : db = Nothing
As you see i release all object variables i use, so there should be no open references that prevent the database from automatically compressing. If i don't open the dialog, i don't get this error. Any ideas or hints whats going wrong here? Thanks...
PS: If testing this you'll have to alter at least one record to give Access a reason to do the compressing...__________________
Greetings, HJB
|
|
Eugene Astafiev
Guest
|
|
Heinz-Josef Bomanns
Posts: 206
Joined: 2008-02-28
|
Hi Eugene,
clAccTables is a combobox that just holds some strings (names of the Access tables), no objects, so Items can't/won't have to be released. Mentioned article i've readed several times since working with ADX and all tips & hints has been followed - all used object variables i've declared and used are relaesed afterwards. Any other ideas? Thanks...__________________
Greetings, HJB
|
|
Eugene Astafiev
Guest
|
Hi Heinz-Josef,
The article I mentioned above doesn't recommend using the For Each loop with COM objects. For example:
For Each td In tds
Do you release the td object each time? |
|
Heinz-Josef Bomanns
Posts: 206
Joined: 2008-02-28
|
Hi Eugene,
thanks, will try that and let you know...__________________
Greetings, HJB
|
|
Eugene Astafiev
Guest
|
Hi Heinz-Josef,
Please keep me notified. |
|