View Full Version : combobox subform problem


Lynn74
12-18-2001, 02:15 PM
If anyone can help i would appreciate it. I am new to access so this might be easy to someone.
I have a frmOperators which has:
*OperatorID
OpLastName
OpFirstName

my fsubCertifications has:
InstrumentType
CertDate

which are both dependent on the OpId primary key
Here's the problem - I made a combobox on last name and after update it fills in the ID and First Name but my subform fields dont change to that record. Then it gives me a message when I close the form that a record cant be delted or changed because table 'Certification' includes a related field. Am I able to even do this???
Lynn

boblarson
12-19-2001, 08:50 AM
Have you tried putting a Me.Requery at the end of your code which updates the info on the main form?

That should get the subform to change if it is tied to the main form correctly.

Bob Larson

Lynn74
12-19-2001, 09:50 AM
Yes i have - but the subform will not go to that record. it comes up with blank fields.
Any other suggestions??

Lynn74
12-19-2001, 10:03 AM
I tried it again ...no matter what I try I always get the error message "The record cannot be deleted or changed because Certification includes related records"

boblarson
12-20-2001, 10:51 AM
Sorry, I didn't quite catch it on the first time around. What got me this time is the phrase: "The record cannot be deleted or changed because Certification includes related records"

Tell me if I'm wrong, but you have the primary key (OperatorID) included in your subform fsubCertifications. If this is the case, you need to remove the ID field from your sub form. You have a one (frmOperators) to Many (fsubCertifications) and what it's trying to tell you is that the ID is a primary key and can't have more than one of the same. If you leave the ID in the query that your subform is based on (as it ties the Certifications into the main Operators table) but don't have it in the sub form.

I recently ran across this same problem while building an application for a charity.

If you have more problems with it go ahead and feel free to email me (as well as posting here) so I can help you tweak it.

BL
mailto:accessbob@hotmail.com

hth

Pat Hartman
12-21-2001, 05:01 AM
You are trying to use the same control for both data entry and form navigation. The two uses are incompatable.

To use a combobox for finding records, add a new combobox to your form and let the wizard walk you through building it. One of the options will be to use the combo to find a record. That is the option to choose. This will be an unbound control. You also need a textbox on the form that can be used for data entry when new rows are being added. You can toggle the visibility of this field so that it is only visible when the NewRecord property of the form is true.

You are getting the error message because you are trying to change the key value of the parent table and you do not have cascadeUpdate specified for the relationship. I don't think you are intentionally trying to change the key value so the solution is to do what I said above NOT to change the relatonship.

Lynn74
12-30-2001, 08:00 PM
thank you both for replying. i do understand what your saying now. i set it up to have another combo and it works fine -- thanks again