473,946 Members | 1,784 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Form & Subforms producing separate records??

31 New Member
Good Morning all,

I have a main form with 3 subforms. All of the input data on all the forms is stored in the same table.

I started getting the message "the changes you requested to the table were not successful because they would create duplicate values in the index".

I decided to check that the form was trying to make more than one record on the same ID (Auto Number with no Duplicates allowed) and that windows wasnt lying.

After changing the "link child field" and "Link Master Fields" to a temporary field which allowed duplicates for each record to be added, instead of all the info going into the one record, it breaks it up into 4 separate records (one for the main form and one for each of the subforms), hence the error message earlier.

Is there anyway to force all of the data from all 3 subforms onto the same record as the main form? I don’t understand why it doesn’t already if the “Link Master/Child Field” is setup?

Any pointers are most welcome!
Dec 5 '06 #1
7 2616
MMcCarthy
14,534 Recognized Expert Moderator MVP
I don't understand your structure. Why are you using subforms if all the records are in one table and why are all the records in one table?

Good Morning all,

I have a main form with 3 subforms. All of the input data on all the forms is stored in the same table.

I started getting the message "the changes you requested to the table were not successful because they would create duplicate values in the index".

I decided to check that the form was trying to make more than one record on the same ID (Auto Number with no Duplicates allowed) and that windows wasnt lying.

After changing the "link child field" and "Link Master Fields" to a temporary field which allowed duplicates for each record to be added, instead of all the info going into the one record, it breaks it up into 4 separate records (one for the main form and one for each of the subforms), hence the error message earlier.

Is there anyway to force all of the data from all 3 subforms onto the same record as the main form? I don’t understand why it doesn’t already if the “Link Master/Child Field” is setup?

Any pointers are most welcome!
Dec 5 '06 #2
philelpko
31 New Member
The project started off simple but then people decided that other things were needed etc.

Originally there was one form/one table. As people added requirementsand more visible (user input) data was needed, I decided to create 3 subforms and hide them behind each other on the main form as there would be enough room for all the information on one subform at a time. (Code works nicely so only one is visible at any one time)

This is how I ended up with 3 subforms on the same table. I take it from your comment this really wasnt a good path to go down?

Would it be better for me to start from scratch with 4 separate table now that I know the 'new' requirements?

Cheers


I don't understand your structure. Why are you using subforms if all the records are in one table and why are all the records in one table?
Dec 5 '06 #3
MMcCarthy
14,534 Recognized Expert Moderator MVP

Would it be better for me to start from scratch with 4 separate table now that I know the 'new' requirements?

Cheers
The short answer is yes. Have a look at the following website.

http://support.microso ft.com/kb/209534/

Mary
Dec 5 '06 #4
philelpko
31 New Member
Cheers!! I think I suspected that I had gone too far adrift but didnt want to admit it as it would mean more work.

Thanks again


The short answer is yes. Have a look at the following website.

http://support.microso ft.com/kb/209534/

Mary
Dec 5 '06 #5
MSeda
159 Recognized Expert New Member
First and foremost examine your structure as mmcarthy advised. If you find you still want to use multiple subforms like on a tab control to enter data into a table try this.

The Main Form and Subforms Allow Additions & Allow Edits are all set to true. The Main form’s Data Entry is set to true and Subforms’ false.
All of the subforms are linked to the Main Form by the Primary Key, in this case ClientCode.

A textbox bound to ClientCode is located on the main form. And contains the following code (In my Form Users Choose a ClientCode, if yours is automatically select like an autonumber there would need to be some slight modifications to the design so that this code runs when a new record is initiated.):

Private Sub ClientCode_Afte rUpdate()

Me.Form.AllowAd ditions = False
DoCmd.Requery "SubformShippin g"
DoCmd.Requery "SubformBilling "
DoCmd.Requery "SubformPrefere nces"

End Sub

This sets the subforms to the record that was just created.
Dec 5 '06 #6
NeoPa
32,585 Recognized Expert Moderator MVP
That seems quite clever.
Does it add the subforms' data to the table when a record (from the main form) is written?
Dec 5 '06 #7
MSeda
159 Recognized Expert New Member
The user enters a ClientCode on the main form first and then enters the data in the subforms which are bound directly to the table. Basically the main form creates a record that is blank except for the primary key and then once subforms are requeried the user enters the data directly into the newly created record.
It seems that since the subforms a linked via the primary key none of this should be neccessary but as philelpko says the subforms will try to enter their data into their own new records despite the fact that their respective data entry properties are set to false.

I should say that this method requires that any fields that are required by the table properties be on the main form and completed before the code runs.
Because of this I've acctually abandonded this particular method in my own project and have users enter data into entirely unbound forms. Data is not entered until they click an "enter" button which executes an event procedure that validates all of the data before inserting the record via an sql statement. I've found this to be the most effective way to prevent entry errors.
Dec 5 '06 #8

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

Similar topics

2
3560
by: Pete | last post by:
Before I get started with the question, does anyone have a (single) good book recommendation for database design? Not an Access-specific book, but something geared toward helping me figure out *what the user wants*. I've had brief formal education about data flow diagramming, but I'm looking for ... more, now that I'm actually running into problems I think stem from the fact that my users can't explain what they need done, compounded by...
4
3341
by: Mike MacSween | last post by:
It's a form, with (so far) 4 tab pages on it, each of which holds 2/3/4 subforms. (I like tabbed forms by the way - do we all?) Basically the subforms are different ways of looking at the data. It's the orchestral management thing still. So tab 1 looks at each musician, the events they're booked onto, which jobs they're doing etc.
3
2780
by: Tony Williams | last post by:
Sorry to repost but I cannot work this out. Can anyone come up with a suggestion? I have a main form based on Table1. The form has a tab control of three pages. Each page has a subform based on a different table ie subform1 based on Table2, subform2 based on Table3 and subform3 based on Table4. I want the user to be able to use the Filter By Form facility in Access but this does not work when trying to select controls on the main form AND...
4
7039
by: Dave Boyd | last post by:
Hi, I have two very similar forms each with a subform. The main form gets a few fields from the user and passes this back to a query that the subform is bound to. The requery is done when the user enters the last qualifying field on the main form. In one case this works fine, the subform shows the data the user wants to update -- which means showing all the data put in previously (ie showing this via the requery and the continuous...
18
13645
by: Darryl Kerkeslager | last post by:
I don't do much with subforms - in fact I've deliberately avoided them - but .... I have a tab control that will contain several subforms, each bound to a separate table, and each table/subform will relate to the same person - but the subform data will not be 'linked' to the main form. I want to have one Cancel button for all the undo operations on all the subforms, so the individul subform's Public Sub, Form_Cancel will be called...
2
2859
by: cefrancke | last post by:
I have a form (no underlying record set) that has two separate sub-forms on it. Each sub-form has data from two different tables. Above each sub-form there is one unbound combo box with a SQL record source that returns an ID field and a Text field. Next to each combo box is two buttons, one that 'Applys' the filter of the sub-form to the value in the combo box and one that 'Clears' the form's current filter. When the click event of the...
3
11985
by: dhowell | last post by:
In reading some of the posts on this group, it appears as though it is not strait forward at all to filter a form, which has subforms, by criteria which are either on subforms or span more than one subform..... This MSDN article however makes it sound as simple as clicking "Filter by Form", entering the search criterial in the form and/or it's subforms, then just clicking "Apply Filter"...... ...
16
7254
by: TD | last post by:
This is the code under a command button - Dim ctl As Control For Each ctl In Me.Controls If ctl.BackColor <> RGB(255, 255, 255) Then ctl.BackColor = RGB(255, 255, 255) End If Next ctl
3
4164
by: ApexData | last post by:
I'm starting a new project. A Personnel System. I have considered opening a single bound form to the main employee table. The user can scroll the records to any individual. I would like to have a tab control at the top of the form which would allow the user to select (PERSONAL), (TRAINING),(DISIPLINARY),and (SICKLEAVE) Tabs. Each Tab should open a FORM and display the relavant TABLE of records tied to the Employee being viewed in the...
0
9977
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
11150
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
11333
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
10685
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
8245
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
7412
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
6106
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...
0
6325
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3533
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.