473,379 Members | 1,255 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Simultaeously Updating Two Tables

Greetings. I have a table (tblLastNum) containing the last report
numbers for several sites, such as:

AL 001
MS 009
IL 020

A second table (tblReports), contains data a user enters on a form,
including a site selected in a combo box (Row Source is the table
above). I don't want the last number at this point because the user
may decide to cancel the record, or another user may submit their
record while this one is still being edited.

When the user clicks on a submit button, I want to:
1) Increment the last report number for the applicable site in the
tblLastNum table;
2) Populate a ReportNum field on the form with the new number (thereby
adding it to the user's record in tblReports).

I got the first step working by running the following update query:
UPDATE tblSites SET tblSites.LastNumber = [LastNumber]+1 WHERE
(((tblSites.Site)=[Forms]![frmReport].[Site]));

How can I do both updates in one step so I don't have a conflict with
multiple users?

Thanks,
Wayne

Mar 24 '06 #1
1 1149
Wayne wrote:
Greetings. I have a table (tblLastNum) containing the last report
numbers for several sites, such as:

AL 001
MS 009
IL 020

A second table (tblReports), contains data a user enters on a form,
including a site selected in a combo box (Row Source is the table
above). I don't want the last number at this point because the user
may decide to cancel the record, or another user may submit their
record while this one is still being edited.

When the user clicks on a submit button, I want to:
1) Increment the last report number for the applicable site in the
tblLastNum table;
2) Populate a ReportNum field on the form with the new number (thereby
adding it to the user's record in tblReports).

I got the first step working by running the following update query:
UPDATE tblSites SET tblSites.LastNumber = [LastNumber]+1 WHERE
(((tblSites.Site)=[Forms]![frmReport].[Site]));

How can I do both updates in one step so I don't have a conflict with
multiple users?

Thanks,
Wayne

Instead of using a query to update, perhaps use a recordset. Ex:
Dim blnExclusive As Boolean
Dim rst As Recordset
On Error GoTo 0
On Error Resume Next
Set rst = CurrentDb.OpenRecordset(strFile, dbOpenDynaset,
dbDenyWrite + dbDenyRead)
blnExclusive = (Err.Number = 0)

You could put something like this in a dowhile. If you know you'll open
table1 first, then table2 then get table1 exclusive, open table2
exclusive, then update then close. Put in something that can pause the
dowhile if blnExclusive is false.

Mar 25 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Bernard André | last post by:
Hi All, context: I am using Access 97 tablkes with VB. I can see records in the MDB, using Adodc and datagrid. No problem. But when doing: rsprivate.AddNew rsprivate!For =...
0
by: cwbp17 | last post by:
Have two tables that have a FK relationship on ID column. Have one datagrid that displays all of the columns of both tables. What's the best approach on updating a row from the datagrid back to...
3
by: Bucko | last post by:
How important do you guys feel locking a database is while updating/adding information? Do you do it with every app you make? Only very high volume (traffic) apps? I'm trying to decide if my app...
1
by: Mark | last post by:
I'm having a problem updating recordsin an Access DB table. I can update other tables in this db with no problem, and I can dreate new record in all of the tables (including this one.)> But I can't...
0
by: cwbp17 | last post by:
I'm having trouble updating individual datagrid cells. Have two tables car_master (columns include Car_ID, YEAR,VEHICLE) and car_detail (columns include Car_ID,PRICE,MILEAGE,and BODY);both tables...
1
by: Gunnar | last post by:
I am finding some unusual behavior with techniques I am using to show/hide/update data without having to refresh the page. I'm quite sure it's developer ignorance on my part and would be grateful...
34
by: Jeff | last post by:
For years I have been using VBA extensively for updating data to tables after processing. By this I mean if I had to do some intensive processing that resulted in data in temp tables, I would have...
4
by: Geoff | last post by:
Hi I'm hoping somebody can help me with the following problem that has occurred to me. Suppose I have two tables in an SQL Server database. Let's call these tables A and B. Assume that A has...
1
by: rdemyan via AccessMonster.com | last post by:
My App has 10 or so tables that we provide that contains proprietary data. This data will need to be updated once or twice a year. I would like some comments, suggestions on my proposed strategy...
5
by: rdemyan via AccessMonster.com | last post by:
I have a need to add another field to all of my tables (over 150). Not data, but an actual field. Can I code this somehow. So the code presumabley would loop through all the tables, open each...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.