Hi, while responding to another issue one of the forums members suggested for good practice I also limit user impute into the RecNum field by inserting the following code into RecNum field so it self populates with the next number
Private Sub RecNum_BeforeUpdate(Cancel As Integer)
If IsNull(Me.RecNum) Then
RecNum = Nz(DMax("RecNum", "tblRecommendations", "ReportID = " & Me.ReportID), 0) + 1
End If
End Sub
I understand the code to some extent in that it is say if tblRecommendations , field RecNum is null then before update a new record add 1 to the pervious number in the field in the tblRecommendations into the RecNum field for the user. I have inserted the code but nothing happens. I have checked all the naming conventions and they are correct
(RecNum and it is stored in the tblRecommendations).
1) My only thoughts are as it is a number field when the new record is created the RecNum field is self populated with a 0
2) The RecNum is not the primary Key the primary key for each RecNum is RecID
3)The frmRecommendations is a subform of frmReportID
Any help greatly appreciated Ron
Private Sub RecNum_BeforeUpdate(Cancel As Integer)
If IsNull(Me.RecNum) Then
RecNum = Nz(DMax("RecNum", "tblRecommendations", "ReportID = " & Me.ReportID), 0) + 1
End If
End Sub
I understand the code to some extent in that it is say if tblRecommendations , field RecNum is null then before update a new record add 1 to the pervious number in the field in the tblRecommendations into the RecNum field for the user. I have inserted the code but nothing happens. I have checked all the naming conventions and they are correct
(RecNum and it is stored in the tblRecommendations).
1) My only thoughts are as it is a number field when the new record is created the RecNum field is self populated with a 0
2) The RecNum is not the primary Key the primary key for each RecNum is RecID
3)The frmRecommendations is a subform of frmReportID
Any help greatly appreciated Ron