views:

1247

answers:

2

I'm working on a program that needs to edit some objects in an Access database. It also runs a subprogram (long story) that tries to access the underlying JET database while Access still has it open via ODBC.

The problem is that as soon as I start editing Form objects using VBA - for example, using Application.LoadFromText - Access changes the database to exclusive mode. Exclusive mode itself is fine, and I know why it needs it. But I need to be able to switch back to "shared" mode afterwards so that I can run my subprogram.

I've observed that if you use the UI to open a Form in Design mode, Access switches the database to Exclusive. (You can confirm this by trying to open it from another computer.) But when you then close the form designer, Access immediately switches it back to shared mode, which is what I would hope for.

Is there a way to switch it back and forth myself using VBA / COM calls?

I know I can call Application.CloseCurrentDatabase() followed by OpenCurrentDatabase(), but that closes all the windows and upsets the UI, so it's not ideal.

+4  A: 

Is splitting the database into a separate front-end with the forms/modules/etc. and back-end with the tables an option? That way if the front-end is locked, the back-end is still accessible. Access has a database splitting wizard for just that.

David
That's an option - and some databases where I'm doing that actually are split this way - but it's non-ideal. I don't need to do operations *while* it's locked, I just need to be able to lock and unlock on demand.
apenwarr
Splitting is the only sensible answer.
David-W-Fenton
If that's true, then it's sad. The databases in question are small and simple, and it's a shame to force them to split just because of a trivial locking issue.
apenwarr
A: 

You might try .UserControl and .Visible. I use them to transfer control in automated processes. I don't know if they will help here, but you can down-vote if they don't.

Smandoli
I'm not sure that will do anything of use. The database is opened exclusively; that's not stopping the VBA app from controlling it.
apenwarr