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

updating Subform

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 3427
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 Expert 1GB
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 Expert 1GB
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
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 Expert 1GB
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
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 Expert 1GB
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 100+
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 tblTBMPartsCosts. 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_BeforeUpdate(Cancel As Integer)
Me.PartCost = Me.PartName.Column(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
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...
4
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...
6
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...
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...
3
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,...
17
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...
4
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...
6
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
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...
0
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...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
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...
0
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...

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.