Make Table query issue (VBA) (1 Viewer)

Paul Archbold

New member
Local time
Yesterday, 21:32
Joined
Sep 19, 2019
Messages
5
New Member! READ ME FIRST

Hi All

I have a make table and i would like to use this on two separate forms. the first form has a button that when pressed runs the make table query & then open a cross tab Form. on this Cross tab form i would like to run the make table query again, and then refresh the data on the form. Unfortunately i am getting an error message saying: "The database engine could not lock table "Data" because it is locked down by another person or process". my investigation and gut instinct is telling me that because the query is already being used by the first form it wont allow it to be used by the second. i am using VBA and the code on the second form is as follows:

Code:
Private Sub RefreshData_Earlies_Click()

DoCmd.SetWarnings False


On Error GoTo Err_RefreshData_Earlies_Click

    DoCmd.Close acTable, "Data"


    DoCmd.OpenQuery "qryFinalReport"

    DoCmd.RunCommand acCmdRefresh

Exit_RefreshData_Earlies_Click:
    Exit Sub

Err_RefreshData_Earlies_Click:
    MsgBox Err.Description
    Resume Exit_RefreshData_Earlies_Click
    
DoCmd.SetWarnings True
    
End Sub
FYI - the table is most definitely not being used by anyone else and the table is not open.

Any help would be much appreciated

Regards

Paul Archbold
 
Last edited by a moderator:

isladogs

MVP / VIP
Local time
Today, 05:32
Joined
Jan 14, 2017
Messages
18,209
Hi and welcome to AWF

Your post was moderated. This often happens when new members post a lot of code.
I also moved your post from the Introduce Yourself forum as its a technical question.
Finally I also added code tags (# on toolbar) to make it easier to read.

Its not clear why you want to run the make table query twice. If the form is based on the table then Access will indeed prevent you overwriting it
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 12:32
Joined
May 7, 2009
Messages
19,229
the crosstab query is based on the new table you made.
now you want to run a new make query to make same table?
 

Paul Archbold

New member
Local time
Yesterday, 21:32
Joined
Sep 19, 2019
Messages
5
The data Is being pulled in from another database which is constantly updating and there fore I wanted to make the table again with the latest data and then refresh the form with the updated data at the press of a button on the form.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 12:32
Joined
May 7, 2009
Messages
19,229
it is constantly updating, which one, the "data". no wonder you cannot hold to lock it.
 

isladogs

MVP / VIP
Local time
Today, 05:32
Joined
Jan 14, 2017
Messages
18,209
You will first need to close the form so the table can be overwritten. Also do not keep creating the table repeatedly as it will lead to instability.
Instead either empty the table using a delete query then run an append query to repopulate it
Or better still use an unmatched query to just append new results plus an update query if existing results have changed



Sent from my iPhone using Tapatalk
 

Paul Archbold

New member
Local time
Yesterday, 21:32
Joined
Sep 19, 2019
Messages
5
The database that is linked to my database is the one constantly updating, which is why I wanted to run the make table query and then refresh the form.
 

jdraw

Super Moderator
Staff member
Local time
Today, 00:32
Joined
Jan 23, 2006
Messages
15,379
Please tell us more about the application that updates the database constantly.
Who or what updates the database?
What is the subject matter in general terms?
What exactly is your role?
What is your database's subject matter/purpose?
Why is that database linked to your database?
 

Users who are viewing this thread

Top Bottom