473,748 Members | 2,422 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to run make table query on an active table used by a form?

35 New Member
I am trying to re-create the existing table once it gets updated via form. However, I am getting error "The database engine could not lock table "tbl_test" because it is already used by another person or process".

Please help me find a way to get around this

Thanks
Aug 2 '10
49 5979
dsatino
393 Contributor
Oh boy. I'm not sure you fully understand what you're getting yourself into here.

From the looks of it, you're trying to build an accounting database from scratch. That would beg the question as to why? You can just buy those in the box and many of them can be accessed via a program like access if you need deeper analysis.

All that aside, your underlying tables are not normalized nor do they appear to be referential. You have no primary keys.

Now for the form. It appears that you didn't really plan it out, but just started building and now you've finally gotten to a point where you can't get something to work and rather than stepping back and reassessing what you've got, you're just trying jam it through. Basically you want to allow the user to directly update the summary data which fires a process that edits the detail which requires the users view to be deleted and remade. Your allowing the user to edit the results directly but making the program run in circles.

Believe me, my programming knowledge is all self-taught so I've been down the road you're trying to follow. Do yourself a huge favor and do some research on the fundamentals of databases, vba, and SQL.

Your SQL, as it is, will update every record that matches the account number criteria. So if change the Name of PSTest, your SQL is also going to change the name of TES. Now you've got two identical accounts in your account table and all your results will double. Be careful with SQL. You can write a lot of things that will return unintended results.

Also, you'll need a decent amount of VBA if you're column headings are going to change every six months. Otherwise you'll never acheive full automation and you'll be constantly updating anything that references the current dates that you're using.
Aug 3 '10 #41
dpatel1682
35 New Member
I agree with you comments regarding doing everything against the standard ways. I had PK and referentials before I received the data and when I looked at the data, I was forced to kill all the PK and Referentials. After reviewing the DB, is there any way to achive what I am trying to do on the same form?

Please advise

Thanks
Aug 5 '10 #42
dsatino
393 Contributor
Anything is possible, but in your case it's going to be difficult.

Your original problem/error is caused by the fact that your form is bound to the table you're trying to delete. You've closed the form visually, but since your code is in this form, the form is still open and hence the table is locked by the form.

What makes your problem difficult to solve is the fact that your process is circular and has no end point.

Table A
Feeds xTab Query
Makes Table B
Bound to Form
Edits to Form change Table B
Which calls process to update
Table A
...

Start by getting your update procedure out of Form and into it's own module. Once you do that, find a way to call the process without the form being open and it'll probably work.
Aug 5 '10 #43
dpatel1682
35 New Member
I am kind of unsure in what do you mean by "Start by getting your update procedure out of Form and into it's own module. Once you do that, find a way to call the process without the form being open and it'll probably work"

Thanks a lot for your help
Aug 5 '10 #44
dsatino
393 Contributor
All of your code is behind forms(CBF). There's nothing inherently wrong with that, but in this case it needs to be outside the form in it's own module.

More specifically:

User updates data in your form
This fires the controls After_Update procedure which tries to run the code you wrote.
The code is failing because the table you're trying to update is bound to the form that is running the code.

If you put this update procedure in it's own module, you can close the form and call the procedure. This will probably allow you to do what you want.
Aug 5 '10 #45
dpatel1682
35 New Member
Can you please provide an example? I am still bit lost as to how do I do this. What I tried to do after the update is click on the "Refresh" button which will close the form, run the make table qry, and re open the form. Should I put the above steps in module and run that module on click ?
Aug 5 '10 #46
dsatino
393 Contributor
Yes, move all the code from the click event(except the form close command) into a module.

On_Click close the form
In the forms on_close event, call the procedure that you moved to the new module.

I think this will work, but I've never tried it
Aug 5 '10 #47
dpatel1682
35 New Member
ok I tried that but it didn't work. I created a module with a function called mktbl which had maketable qry followed by open form command. It gave me the same error when it tries to execute maketable qry

Any other idea?

Thanks for your help
Aug 5 '10 #48
dsatino
393 Contributor
Clear the on click event from the button and paste this into it:

Expand|Select|Wrap|Line Numbers
  1. Me.tbl_Raw_Data_by_Account_subform.Form.RecordSource = ""
  2. DoCmd.RunMacro "mcr_mktbl_Raw_Data_by_Account"
  3. Me.tbl_Raw_Data_by_Account_subform.Form.RecordSource = "tbl_Raw_Data_by_Account"
  4. Me.Refresh
  5. Me.Requery
It will get you buy the error, but this is really frowned upon.
Aug 5 '10 #49
dpatel1682
35 New Member
It worked. I used the following Code

Expand|Select|Wrap|Line Numbers
  1. tbl_Raw_Data_by_Account_subform.Form.RecordSource = ""
  2.  
  3. DoCmd.RunMacro "mcr_mktbl_Raw_Data_by_Account"
  4.  
  5. tbl_Raw_Data_by_Account_subform.Form.RecordSource = "tbl_Raw_Data_by_Account"
  6.  
  7. tbl_Raw_Data_by_Account_subform.Form.Refresh
  8.  
  9. tbl_Raw_Data_by_Account_subform.Form.Refresh
Aug 5 '10 #50

Sign in to post your reply or Sign up for a free account.

Similar topics

11
16298
by: randi_clausen | last post by:
Using SQL against a DB2 table the 'with' key word is used to dynamically create a temporary table with an SQL statement that is retained for the duration of that SQL statement. What is the equivalent to the SQL 'with' using TSQL? If there is not one, what is the TSQL solution to creating a temporary table that is associated with an SQL statement? Examples would be appreciated. Thank you!!
4
2393
by: Oreo Bomb | last post by:
I have a secured database that contains a Read-Only group. This group has permissions to view reports, but cannot add, edit, or delete any DB objects. One of the reports the group needs access to is generated with a Make-Table Query. Since the Make-Table Query deletes the previous table it created everytime it's ran, this poses a problem since the Read-Only group doesn't have the permission to delete objects. This causes the report...
4
2609
by: DebbieG | last post by:
I have a form based on this query: SELECT Students.LastSerDT, OtherInfo.Served, OtherInfo.HSGradYr, OtherInfo.ActivePart, OtherInfo.Served, Students.SSN, & ", " & & " " & AS Name, Students.LastNM, Students.FirstNM, Students.MI, Students.DOB, Students.GenderCD, Students.EthnicityCD, Students.EligibilityCD, Students.UBInitiative, Students.NCESSchID, Students.ProjEntryDT, Students.ProjReEntDT, Students.LastSerDT, Students.Reason,...
1
2050
by: bmoos1 | last post by:
I have a form that when the monthly payment is entered, it calculates the annual payment. The correct numbers appear in the form, but they are not in the table or query from which the form was created. The calculation is done in the form. All new record entries update the query/table, but I need to get those records that were there before the form was created updated with the annual payment so that my year-end report is correct. I...
2
2104
by: Doc | last post by:
Per earlier post, I am trying to save 'out' production data from a program called Solomon - basically (I think) this was /is an Access/Sql based program. We are updating to different application and I need to bring over ONLY certain DATA. When I did an ODBC link to the DB all the tables are present. I linked the three or four tables and have my fields (these are the ones I want to modify for LATER import into the new application)
0
2014
by: The Frog | last post by:
Hello Everyone, I have been asked to try and create a single SQL query to retrieve product information from a database. The way that data is arranged is that in some tables there are user defined "attributes" or "dimensions" that in turn connect to the actual product table via a many-many (using a linking table). In each linking table there is a combination of the "dimension", the productID, and the "fact" that is stored against the...
2
1529
by: sbitaxi | last post by:
I have a query that performs a simple sum, a running total essentially. I want to be able to use that in a calculation in a form but I can't seem to get it to display anything beyond #Name? Structure - Table A feeds the primary form, recording particulars about a mailing and calculating costs Table B feeds a sub-form, line items to track individual expenses in the mailing
19
2199
by: MNNovice | last post by:
I have a Form where there are various combo boxes. These combo boxes are used as references for the parameter of various fields in a query. A command button opens a query with the parameters selected from the form. I am having problem with two combo boxes which pulls data from the same table. These two combo boxes are called: txtActor and txtDirector. I am trying to generate a query to display any combination of actor and director (Or...
2
2394
by: Laurel | last post by:
I am completely new to access. I have a make-table query that combines data from two/more tables, asks for a criteria, deletes the old table and produces a new table every time under the same name. The table is always linked up with a form to allows user to fill in certain rolls of the table. A. How would you make the form pop out after the make-table query is done and the new table is made? Can I add a openform procedure in the sql code of...
6
2620
by: Debbie Toney | last post by:
Access 2007 3 table query: Contact table, Event table, Payment table. Contact may have an Event but no Payment, a Payment but no Event, or an Event and Payment. My query is duplicating the Event and Payments. I have attached an example: The Contact Smith has 2 Events (Rome night and Men club) and 2 Payments ($4000 and $100) that are not associated. I want the query to return 4 records: 2 showing the Payments with associated Contact info...
0
9558
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9378
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9331
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9253
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6798
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6077
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2216
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.