
Originally Posted by
ssanfu
Because the two tables are linked and RI is enforced, you MUST have a value from Profile_Table.Profile_ID in Log_Table.Profile_ID_SK.
You are trying to create a record in Log_Table.Profile_ID_SK that has a value of 0, but there is no record with a value of 0 in Profile_Table.Profile_ID
You have the Profile_ID (PK field) from the "Profile_Table" for a person in the openargs argument but you NEVER USE IT.
So on the form "AddLog_Form", you need to have a hidden text box control bound to the "Profile_ID_SK" field.
When the "AddLog_Form" opens, code in the on load event code takes the value in the openargs argument and puts it in the "Profile_ID_SK" text box.
THEN you can save the record.
PS... it looks like you might have problems with the delete log row code also. Are you wanting to delete ONE specific log record or ALL log records for a specific person??
Thanks for your answer
What do you mean i have a problem with the delete log row button?
The idea is that it should delete the row that i select in the listbox named Log_Listbox
And as far as i can tell it does that... or what am i missing (i bet i am missing stuff all the time)
On the other matter.... I think i got it to work!
I did this:
In the form Profile_Form in the button "add log row" event on-click i added this code
Code:
DoCmd.OpenForm "AddLog_Form", , , "Profile_ID_SK = " & Me.txtProfile_ID, acFormAdd, , Me.txtProfile_ID
On the startup event of the form called AddLog_Form i added this code
Code:
If Not IsNull(Me.OpenArgs) Then
Me.txtProfile_ID_SK = Me.OpenArgs
End If
And now i think it works as i want it to work.
However a follow-up question.
How to eliminate the error messages that appear when someone click on the button and nothing is selected in the Profile listebox... i understand that i need something to tell that "if the txtprofile_id is empty or null then dont run the code".... is this right?
Uploaded a new file with this working ad described.