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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cannot add record error

Status
Not open for further replies.

THWatson

Technical User
Apr 25, 2000
2,601
CA
Using Access 2000

A form, frmCustomers, has 2 tab pages. On the first is frmCustomers based on tblCustomers. On the second is fsubProjects based on tblProjects. They are linked by CustomerID.

I try to enter a new customer. When I type the second character in the Last Name field, I get the message:
"You cannot add or change a record because a related record is required in tblCustomers." But I am on the form which is based on tblCustomers?

Additionally, the mere clicking on the Projects tab adds a project to tblProjects.

Any suggestions of where to look to track down the problem?

Thanks.

Tom
 
Sounds like a funky table relationship got created somewhere - maybe something involving cascading updates/deletes?

"Business conventions are important because they demonstrate how many people a company can operate without."
 
Well, referential integrity is on...but cascades/deletes are not.

Tom
 
Howdy THWatson . . .

I believe I see the same [blue]ambiguity[/blue] as [blue]genomon[/blue]:
THWatson said:
[blue]A form, [purple]frmCustomers[/purple], has 2 tab pages. On the first is [purple]frmCustomers[/purple] based on tblCustomers.[/blue]
Can you see it! . . . I hope this is just a typo! . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
TheAceMan1
I most apologize for creating ambiguity. Yes, it's a typo. The form is frmCustomers. There are 2 pages. The primary page has the controls for tblCustomers. Then there is a tab control page which has fsubProjects.

This piece of the database goes back to the earliest construction. Somewhere along the line, something has crept in.

When I go back to the first version, the problem does not occur. But it does occur with later versions.

Changes have been made on fsubProjects (for example, the stuff you were helping me with the other day). But nothing has changed on the frmCustomers.

Now, as soon as I put one character in a new record, I get the following...
1. the error message "You cannot add or change a record because a related record is required in tblCustomers." If you press OK you can continue with the record.
2. Clicking on Next record adds a new Project.
3. Going to a different record by use of a combo box adds a new Project.
3. Clicking on the Projects tab adds a new project even if you don't put any data in any project.

What I haven't yet figured out is at what stage of development this problem developed...since it wasn't there at the outset.

Tom
 
The problem was that I had code in the Current event of fsubProjects that was creating values in 2 hidden bound controls, and this was firing as soon as I entered a new record in frmCustomers.

Moving that code to the Dirty event has solved it.

Tom
 
THWatson . . .

Excellent! [thumbsup2]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top