Code:
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Problem_record") 'Form Recordsource = Nonconformance_Record tbl
If Me.Dirty Then Me.Dirty = False 'force record save
Debug.Print "Key is " & Me.nonconformance_record_NonconformanceRecordID
'Loop through the ItemsSelected in the list box.
With Me.lstCAR
'here we are getting the Problemid of the selected Items '*********************************
For Each varItem In .ItemsSelected
If Not IsNull(varItem) Then
rst.AddNew
recCnt = recCnt + 1
rst!ProblemID = lstCAR.ItemData(varItem)
debug.print "added from lstCAR # " & reccnt & ", " & lstCAR.itemdata(varItem)
Me.problem_record_NonconformanceRecordID = Me.nonconformance_record_NonconformanceRecordID
rst.Update
End If
Next
End With
Add the redline to see what's happening
Also note that your code will not update existing records in Problem_Record. It will only create new records.