Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

form with subforms in tabs

Status
Not open for further replies.

signallt03

Technical User
Mar 14, 2003
21
US
I have a main form (frm_Cadet) on it there is a tab control with six different tabs. The first tab has a subform (frm_CDTInfo) it contains general information about each cadet ie. Name, SSN, Date of Birth.

The other tabs contain subforms linked to the first one, via SSN, with info about different tests and skills training.

I am using this form to both update and add new cadets to the database.

The problem I am running into is that when after i enter the main info on tab CadetInfo and then try to enter info on the next tab i get an error. "You cannot add or change a record because a related record is required in table "tbl_Cadet". the info for tbl_Cadet should be coming from the first tab.

Thanks
signalLT03
PRO PATRIA VIGILANS
"Watchful for the country"
 
Basically what is happening is that the record on the Main form is not being transferred to the tables and being read back for the subforms to relate to it, at the end of the update sequence or as you move to the next tab add:
DoCmd.RunCommand acCmdSaveRecord

Frank J Hill
FHS Services Ltd.
frank@fhsservices.co.uk
 
You have got major problems!!!
First - the main form should be the major input form for the Cadet detail at the moment you are using a subform which even thogh it saves to the table of Cadets it is not refreshing the Main form and then finding the appropriate record for you to carry on entering data. This van be overcome by using:
DoCmd.RunCommand acCmdSaveRecord
Me.Requery
DoCmd.GoToRecord,,,acLast

Second - you do not have the Primary Key SSN in the School subform so there is no way you can tie the data entry to the SSN displayed in the main form.
Semester is also a Primary key but is not set as Required in your tables.

I have not checked the remainder of the subforms for SSN entry but suspect that it will be missing from all.

Frank J Hill
FHS Services Ltd.
frank@fhsservices.co.uk
 
trendsetter-
I tried messing around with the code from above but having a hard time trying to figure out where to place it. ie. on form change or what?

thanks
signallt03
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top