I thought I had this licked and behind me a week ago, but under slightly different conditions I found a bug that's kept me busy for 1/2 a day. Either I'll solve this while writing this description (a frequent occurrence) or I'll put it in your capable hands. I'm ready to move on. I have two fields in a the subform's table that need to be populated by the two fields that make up the primary key in the master table, P_RegNo and Admit_Date. The subform is a continuous form and as each record is keyed a row for a new record is created. I was using the On Current event to populate these fields.
Code:
Private Sub Form_Current()
Me.txtP_RegNo = Form_Clinical_Summary.P_RegNo
Me.txtAdmit_Date = Form_Clinical_Summary.Admit_Date
End Sub
This is causing this error message "Index or Primary Key cannot contain a Null." on several events. When I first wrote this I did not seem to have this problem.
What I want is for each new record to populate those new fields, .... ah ha!
OK, here is my right now solution. I've moved this code to my forms Before Update event which appears to have fixed the problem. I always get ideas as I'm laying out these problems and about half the time I come up with "a" solution, if not "the" solution. I'm not going to mark this solved just yet, so if you have any comments or insights, please add them.