473,320 Members | 1,845 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,320 software developers and data experts.

Parent Form (based on Query) Write Conflict [Access 2003]

110 100+
All,

I have a Parent form where the Record Source is a query based on three tables (tblcustomers, tblEquipment, and tblWorkOrders).

The Parent form has a subform based on a 4th table (tblServiceVisits). When the code from my subform attempts to update controls on the parent form (i.e. refresh the date to the current date and change the status of the work order) I get a write conflict error.

To clarify, I'm getting the error as soon as the parent form gets the focus back. I believe it is because the the information has not been written to the record when the parent form regains focus.

Is there anything along the lines of:

Me.Parent.SaveRecord

Many thanks in advance for any insight.

Gunner
Jun 9 '10 #1
4 2014
patjones
931 Expert 512MB
Can you post the code that you are working with? I'd especially like to see the queries that the parent and sub forms are based on. Thanks.

Pat
Jun 11 '10 #2
dgunner71
110 100+
Pat - Here is the posted code below - this code is located in the subform with the fields to be updated on the parent form. (I changed from Me.Parent to the code below.)


Private Sub dtDateScheduled_AfterUpdate()

Forms!frmWorkOrders.Form.txtWorkOrderStatus = "Open Work Order"
Forms!frmWorkOrders.Form.dtStatusDate = Now()

End Sub

I'm not 100% sure how I should post the query - I've include the sql below (this is the Record Contorl Source for the parent form):

SELECT tblWorkOrders.*, tblEquipmentServiced.*, tblCustomers.*, Switch(tblEquipmentServiced!txtType="Elliptical"," EL",tblEquipmentServiced!txtType="Treadmill","TR", tblEquipmentServiced!txtType="Home Gym","HG",tblEquipmentServiced!txtType="Recumbent Bike","RB",tblEquipmentServiced!txtType="Upright Bike","UB",tblEquipmentServiced!txtType="Stepper", "ST") AS MType, Switch([txtWorkOrderStatus]="parts on order - Not Confirmed","Not Confirmed",[txtWorkOrderStatus]="parts on order - Confirmed","Confirmed",[txtWorkOrderStatus] Like "*Partially*","Partially Rc'vd",[txtWorkOrderStatus]="Stock Parts on Order - Confirmed","SP Confrimed",[txtworkorderstatus]="Stock Parts on Order - Not Confirmed","SP Not Confirmed") AS StatusModifier, IIf(nz([dtPurchaseDate],"MT")<>"MT",[dtpurchasedate],IIf([numYearsPurchase]>0,[numYearsPurchase] & " Year(s)","None Entered")) AS Bought, IIf([txtSecondaryContact] & ""="",[txtFirstName] & " " & [txtLastName],[txtFirstName] & " & " & [txtSecondaryContact] & " " & [txtLastName]) AS CustFullName
FROM (tblCustomers INNER JOIN tblEquipmentServiced ON tblCustomers.numCustomerID = tblEquipmentServiced.numCustomerID) INNER JOIN tblWorkOrders ON tblEquipmentServiced.numEquipment = tblWorkOrders.numEquipment;

The subform (sfrmServiceTrips) has a control source of tblServiceTrips.

Thanks again for taking the time to help.

Gunner
Jun 12 '10 #3
dgunner71
110 100+
Pat - I got it working by changing the existing script to that below:


CurrentDb.Execute "Update tblWorkOrders set [txtWorkOrderStatus] = 'Open Work Order' where numWorkOrderNo = " & Me.Parent.Form.numWorkOrderNo
CurrentDb.Execute "Update tblWorkOrders set [dtStatusDate] = '" & Now() & "' where numWorkOrderNo = " & Me.Parent.Form.numWorkOrderNo


I found the code here: http://www.utteraccess.com/forum/Sav...-t1857095.html


The was a DBEngine.Idle dbRefreshCache included after the script, but it did not work properly and does not appear to have an adverse effect by commenting it out.

Thanks again for your help.

Gunner
Jun 13 '10 #4
patjones
931 Expert 512MB
What you posted for dtDateScheduled_AfterUpdate would not work, because if the controls in question, namely txtWorkOrderStatus and dtStatusDate are already bound to a recordset, trying to explicitly assign values to those controls would be like trying to edit the record without actually telling Access that you are trying to edit the record. Thus you get a write conflict error.

However, what you tried next works because in using the SQL UPDATE, you are telling Access that you want to edit the underlying recordset that the form is based on, and it thus allows you to do so.

Anyway, I'm glad you managed to get it sorted out.

Pat
Jun 14 '10 #5

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

Similar topics

2
by: cwhite | last post by:
I'm having problems with a form based query The user makes a selection from a drop box, there are only two choices: Current Former the user makes a choice and clicks the preview report...
5
by: SeanCly10 | last post by:
Hi all. I don't want to sound like a complete idiot here, but I'm somewhat limited in my coding knowledge, and I need some advice and help. I'm working on a database that will eventually be used...
3
by: billelev | last post by:
hi, Does anyone know how you would select, from a table of data, only the distinct values for one field that always appear with each value in a second field? For example...Suppose the data is...
7
by: dscarbor | last post by:
I have a simple form with 4 fields, and a subform that retrieves records that are potential matches based on a query. The user will use the ID from the subform record and enter it into one of the...
2
by: eskelies | last post by:
Hello all, I have data, which is separated into account numbers (ie. 10, 20, 30), but it exists in one query. Right now, I have an access macro "transferspreadsheet," which is exporting all the...
7
by: darnnnel | last post by:
I have a form and a subform. The subform is displayed as a datasheet. When a user selects a record on the list, I would like the parent for to show the contents of the record selected. Access 2007,...
5
Dököll
by: Dököll | last post by:
Hey Fans! Perhaps you can help me... I am using MS Access 2003. I have tried a number of things to get rid of the text #Error from appearing on form fields when no data present. Tried the...
5
by: iChappy | last post by:
I have a query based off of two fields in an Access form: Fiscal Week (user manual inputs #) & Fiscal Year (combo box defaulted to current year however may select other years) The query is a...
1
by: MikeMikerson | last post by:
Hello, I am need to create a subform (no problem) of a form based query (a problem). I need a form that will prompt the user to enter in a name, and the form will then display a query of the...
5
by: Bugran | last post by:
I am trying to copy a textbox field on a form (which basically contains the body of a letter) into a memo field in a table (Access 2003) for later printing later. Of course Access queries/SQL will...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.