Hi all,
I have code attached to the BeforeUpdate event for each of 12 columns (which correspond to 12 months of the year).
I know this is possible with a custom function of some sort but would anyone know how I could get this 'built in' and not have to have 12 sub routines?
What they are saying is if there is any value in any of the other month columns, then you cannot enter an amount.
I have the examples for apJan, apFeb and apMar.
Code:
Private Sub apJan_BeforeUpdate(Cancel As Integer)
If Nz(Me.apAug, 0) + Nz(Me.apSep, 0) + Nz(Me.apOct, 0) + Nz(Me.apNov, 0) + Nz(Me.apDec, 0) + Nz(Me.apJul, 0) + Nz(Me.apFeb, 0) + Nz(Me.apMar, 0) + Nz(Me.apApr, 0) + Nz(Me.apMay, 0) + Nz(Me.apJun, 0) > 0 Then
MsgBox "This record has an amount in another month"
Me.apJan.Undo
Cancel = True
End If
End Sub
Private Sub apFeb_BeforeUpdate(Cancel As Integer)
If Nz(Me.apAug, 0) + Nz(Me.apSep, 0) + Nz(Me.apOct, 0) + Nz(Me.apNov, 0) + Nz(Me.apDec, 0) + Nz(Me.apJan, 0) + Nz(Me.apJul, 0) + Nz(Me.apMar, 0) + Nz(Me.apApr, 0) + Nz(Me.apMay, 0) + Nz(Me.apJun, 0) > 0 Then
MsgBox "This record has an amount in another month"
Me.apFeb.Undo
Cancel = True
End If
End Sub
Private Sub apMar_BeforeUpdate(Cancel As Integer)
If Nz(Me.apAug, 0) + Nz(Me.apSep, 0) + Nz(Me.apOct, 0) + Nz(Me.apNov, 0) + Nz(Me.apDec, 0) + Nz(Me.apJan, 0) + Nz(Me.apFeb, 0) + Nz(Me.apJul, 0) + Nz(Me.apApr, 0) + Nz(Me.apMay, 0) + Nz(Me.apJun, 0) > 0 Then
MsgBox "This record has an amount in another month"
Me.apMar.Undo
Cancel = True
End If
End Sub
Any help would be gratefully received!
Nick