I am having difficulty updating records since I referentially linked a field. The following code was working fine and allowing me to add records. Since I linked the ProbNum field in 2 tables, I am now getting an error that states "you cannot add a record or change a record because a related record is required in the 'table'"..... Notably it works sometimes and others it does not work. I am adding the field 'Probnum' which is the related field? any ideas?
field1 = rec("ProbNum")
field2 = rec("goal")
field3 = rec("checkbox")
field4 = rec("daystocomplete")
rec2.AddNew
rec2("ProbNum") = field1
rec2("goal") = field2
rec2("PatNum") = intPatNum 'this is a function
rec2("GoalDate") = Date + field4
'Stop
rec2.Update
field1 = rec("ProbNum")
field2 = rec("goal")
field3 = rec("checkbox")
field4 = rec("daystocomplete")
rec2.AddNew
rec2("ProbNum") = field1
rec2("goal") = field2
rec2("PatNum") = intPatNum 'this is a function
rec2("GoalDate") = Date + field4
'Stop
rec2.Update