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!

Save Form for subrecords - Foreign Key Error?

Status
Not open for further replies.

misscrf

Technical User
Jun 7, 2004
1,344
US
I put this command:
DoCmd.RunCommand acCmdSaveRecord

on the after update of the first field on a subform. I do that because sometimes the user will enter just 1 peice of information, and then want to hit a subform button that is going to allow them to enter "sub" record information for that "sub" record.

so Main form
Subform
Subform button that is just for the current subform record.

The problem is that the popup subform can't open unless it has a subform ID to tie it to. For that reason I try to trigger saving the record the minute a user starts to create one.

This is giving me an error that says:

Run-time error '3146':
ODBC--call failed.

[Microsoft][ODBC SQL Server Driver][SQL Server] The INSERT statement conflicted with the FOREIGN KEY constraint "tblContractDeal_tblDeal". The conflict occured in the database "CompanyContractsBE", tabl "dbo.tblDeal", column "PKDealID" (#547) [Microsoft][ODBC SQL Server Driver][SQL Server] The

and that's it. The funny thing is that the first field is actually FKPartyType, which is not what the error is mad at.

Wierd. Anyone seen this kind of thing before, or know how to trigger a safe of a subrecord as soon as it starts?

Thanks!

misscrf

It is never too late to become what you could have been ~ George Eliot
 
I ended up fixing this by checking the SQL backend table. That foreign key field was set to a 0 default which was causing issues. Once I removed that it now saves once there is a choice made in this first field. Whew!

misscrf

It is never too late to become what you could have been ~ George Eliot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top