Question Error - Table already open exclusively

branston

Registered User.
Local time
Today, 19:08
Joined
Apr 29, 2009
Messages
372
Hi.

Lets start from the begining... I have a table (TblA). I have 2 queries, QryA and QryB both using TblA (QryB also uses other tables). Each of the queries are used in seperate forms (FrmA from QryA and FrmB from QryB).

FrmB has a button which has the following code attached:

Dim IntMax As Integer
Dim StrOpen As String
IntMax = DMax("ANo", "TblA")
StrOpen = "[BNo]=" & IntMax
DoCmd.Close acForm, "FrmB"
DoCmd.OpenForm "FrmA", , , StrOpen

But when i press the button it comes up with an error:
"The table 'TblA' is aalready opened exclusively by another user, or it is already open through the user interface and can not be manipulated programmatically"

Any idea how I can get around this? Or why it might be happening?

Thank you!
 
My best guess is that the DMax function is causing the problem, although it's not one I use much so I can't be sure.

One test would be to comment out the lines of code that form the criteria and see if you can just get the forms to close and open properly.

If this does work, then try an alternative to DMax. For example, could you sort your QryA by ANo? Then you could just go the last record. A less neat route is to open up QryA as a recordset, find the max ANo this way and then use it to form your criteria.
 
Hey. Thanks for the reply Kafrin. I comented out the where criteria, and the variable, so teh code was just saying to open the form, but the error still comes up im afraid. Any other ideas out there?
 
Just thought - forgot to mention something which might be vital!
I used to have FrmB running from a seperate table, which had nothing to do with TblA or the queries. When it was set up like this it worked fine. I changed it to run from a query as I knew it was a better way of organising things, and i required some of the info from tblA. Does that give anyone a further idea of what might be wrong?
 
Hi.

Lets start from the begining... I have a table (TblA). I have 2 queries, QryA and QryB both using TblA (QryB also uses other tables). Each of the queries are used in seperate forms (FrmA from QryA and FrmB from QryB).

FrmB has a button which has the following code attached:

Dim IntMax As Integer
Dim StrOpen As String
IntMax = DMax("ANo", "TblA")
StrOpen = "[BNo]=" & IntMax
DoCmd.Close acForm, "FrmB"
DoCmd.OpenForm "FrmA", , , StrOpen

But when i press the button it comes up with an error:
"The table 'TblA' is aalready opened exclusively by another user, or it is already open through the user interface and can not be manipulated programmatically"

Any idea how I can get around this? Or why it might be happening?

Thank you!

Seems strange, but you could try the "IsLoaded" fn to see whether the form is already active.
 
Well, all the forms are closed apart from the one that has the button on it (which is closed via this bit of code) and the one that is opened via this code.

Not quite sure which form i should have been checking was laoded?
 

Users who are viewing this thread

Back
Top Bottom