473,698 Members | 2,690 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

updating Subform

6 New Member
Hi,
I have 2 subforms in my main form each of them has its own Autoincrement ID number.
When I try to add new record and filling table fields It showing me an error :The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship.

I know the problem is with the auto increment field that is not updating, any way to do it ??

Thanks
Sep 5 '06 #1
8 3440
bassamsuha
6 New Member
Hi,
I forgot to minsion that one subform is from query when i try to update or add new record i got this error (Field cannot be updated).

Thanks in Advanced.
Sep 5 '06 #2
PEB
1,418 Recognized Expert Top Contributor
This is an unupdatabale query! And you can't use it to update information by it!
You have to transform your query in updatable by using table / or linked tables that can be updated!

In function of the link the query may be updatable or not!

Take care what kind of link are you doing and which table you will edit, append or update with your select query!
Sep 5 '06 #3
PEB
1,418 Recognized Expert Top Contributor
And your child field in the properties window for the subform have to be a field that is indexed but allows dublicates!

And your master field have to be a key for the main form!
Sep 5 '06 #4
bassamsuha
6 New Member
Thanks Bep I really appreciate your queck help.

What I understood is that I need a select query to get my records and another update query and another append query to do both actions.

the question is: how to call these two queries?? from where??
I have Add new button and Save button.

Thanks in Advanced
Sep 5 '06 #5
PEB
1,418 Recognized Expert Top Contributor
In fact the only thing that I said is that:

YOU NEED TO USE AN UPDATABLE SELECT QUERY FOR YOUR SUBFORM /S

IF it isn't the case so you have to think how to do your queries updatable! It's NOT by Append or Update queries! It's by changing your SELECT query!

If you want you can describe your query : tables, links and fields from tables and see here what we can do together!

About the forms!

For each control that is displayed in the form have properties! The subform which is located in the form also has properties that you can see them clicking in the respective subform once pressing the right mouse bouton if you are with right handing mouse and choose properties!

In the properties you have to flook for Link master field and link chield field properties!

Those properties do the connection between Main and subform!

Principally In the Chield Field /s we enter information from the main form that concerns the subform! The relation is: the first field from Link Master Fields corresponds to the first field from Link Chield Fields!

You have to be carefull about the information that you type in those fields!

Hope that this time I've been more explicit! ;)
Sep 5 '06 #6
bassamsuha
6 New Member
Thanks again Peb, this problem has been solved.
I have another issue that i want one field in the subform to be a combo box when one of the value selected, rest of the fields should be changed to match the selected value.
any idea on how to do it.
Sep 5 '06 #7
PEB
1,418 Recognized Expert Top Contributor
In fact when the user choose a value from the combo box, Values in other columns in the combo box have to be placed in the fields of your subform, is this your question?
Sep 5 '06 #8
comteck
179 New Member
Not sure if this is what you are looking for, but here is what I did for a similar situation. What happens in my case is I make a selection from a pull-down list from the combo box, and the price appears in the text box.

I have 2 tables with following fields:

tblrefPartsList is just a list of all the parts and a second column listing the price for each part. It has the following fields:
PartID - Autonumber (PK)
refPart - Text
refCost - Currency

tblTBMPartsCost is the child table that stores all the parts used for each customer. It has the following fields:
TBMID - Number (PK)
PartID - Number (PK) - Same as PartID in tblrefPartsList
PartName - Text - Same as refPart in tblrefPartsList
PartCost - Currency

My subform is based on tblTBMPartsCost s. There are 3 controls on the subform - 1 combo box, and 2 text boxes. The combo box is tied to the PartID. Its RowSource property has the following:

SELECT DISTINCTROW [tblrefPartsList].[PartID], [tblrefPartsList].[refPart], [tblrefPartsList].[refCost] FROM [tblrefPartsList];

The following properties has to be set in the combo box as well:
Column Count - 3
Column Width - 0";0.5";0"
Bound Column - 1

PartName is another textbox included on the subform. It has no code associated with it.

The other textbox is PartCost. It has the following BeforeUpdate event procedure:

Private Sub Cost_BeforeUpda te(Cancel As Integer)
Me.PartCost = Me.PartName.Col umn(2)
End Sub

Hope this helps.
comteck
Sep 5 '06 #9

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

Similar topics

5
2441
by: Mary Litten | last post by:
Hi - (This is my very first post) I have gotten to this point of registering to post because I have been spinning my wheels so long, I believe I am all caught up in the weeds. (and mud) I have a form, that has several tabs. On one tab, I have a subform (wr_completion_subform). This subform is bound to a table (wr_completion_table). On the subform, I have a button from which I have added code to email a report of the completion data...
4
2276
by: Laura | last post by:
Here's the situation: I'm trying to use an update query to copy data from one row to another. Here is the situation: I have 5 companies that are linked to each other. I need to show all 5 companies on a form. 3 of the companies have common employees. I have a table that looks like this:
6
1577
by: DP | last post by:
hi, i need a little help. i have two tables and 2 forms, one with a subform. i have a 'fildID' in one of the subforms, and i have another table, which has the film information, including a checkbox, if the film is available. if i enter an id in the subform in filmid, how can i get the checkbox in another form to become unchecked?? (to show that the film is unavailable)
1
2715
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 for updating these tables via an ftp site: 1) Post a .mdb file to our ftp web site that contains the updated tables. My App code connects to the ftp site and gets the file name for any update files on the site. I already have code to do this...
3
2221
by: stuart.medlin | last post by:
I have an Access 97 application that has a basic form (Transcript) and subform. The subform has a query as a recordsource that returns records from a table: SELECT DISTINCTROW Transcript.NCID, Transcript.TransCode, Transcript.TransMM, Transcript.TransYY, Transcript.DateKeyed, Transcript.UserID FROM Transcript WHERE datekeyed >= begindate() and datekeyed < enddate() ORDER BY datekeyed;
17
2587
by: lokidog | last post by:
I am trying to automatically transfer data from one textbox to another between subforms within a 'main' form. I put this code into the Gotfocus eventprocedure: Private Sub Date_GotFocus() If Len(Trim$(Me!.Value & "")) = 0 Then 'This checks for blank or space-filled date field - it will only transfer data if it has not already been entered. Me! = !!.!.! SendKeys "{F2}" SendKeys "{TAB}"
4
8834
by: Macbane | last post by:
Hi, I have a 'main' form called frmIssues which has a subform control (named linkIssuesDrug) containing the subform sfrmLink_Issues_Drugs. A control button on the main form opens a pop-up form which allows me to edit the record in the subform. What I want to happen is for subform with the new edits to be updated on the main form when I close the popup. I'm sure this is a very small bit of code in the the 'On close' event for the popup...
6
3677
by: Dave | last post by:
I want to put the information that the user selects in my combo boxes into a subform that lies on the same form as the combo boxes. Thanks for your help already, Dave
0
1844
by: jwbird | last post by:
I have a main form with multiple Subforms that are all displaying Datasheet information related to the Main form record. When I make changes/adds to the records(s) in the subform and tab to another subform, it saves those previous subform records fine, but when I make changes to the subform records and then change the mainform criteria, it doesn't save those subform records. I can use an event to prompt for saving the records on the...
0
1364
by: skips84s | last post by:
I have a parent form with four tabbed subforms. On subform x, selecting a value from a combo box should update a few controls on this subform, as well as a control on subform y, all done using dlookups. Each of the controls does have a valid control source in the same table. Right now, I can update the controls on subform x with no problem. When I add the code to update subform y, however, the control in subform y updates and saves the...
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
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
9031
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...
0
8871
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
6528
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
5862
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
4371
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...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2007
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.