This does it copied it from another form:

Thanks Bob
Private Sub Form_Current()
Dim frmControl As Control
'If the difference between InvoiceDate and currentDate
'is greater than one or more years then lock all controls
'of the forms therefore you can't edit or delete
'that old Invoice.
Dim dDate As Date
Dim nCountDaysOfYear As Long
Dim dtDiff
dDate = IIf(tbBillDate = "" Or IsNull(tbBillDate), Null, tbBillDate)
Dim nLeapYearNow As Long, nLeapYearOfBillYear As Long
Dim nTotalDays As Long
'Fixed the error of Date difference.
dtDiff = DateDiff("d", Format(dDate, "dd/mm/yyyy"), Format(Now(),
"dd/mm/yyyy"))
nLeapYearOfBillYear = DatePart("yyyy", Format(dDate, "dd/mm/yyyy"))
nLeapYearOfBillYear = nLeapYearOfBillYear Mod 4
nLeapYearNow = DatePart("yyyy", Format(Now(), "dd/mm/yyyy"))
nLeapYearNow = nLeapYearNow Mod 4
If nLeapYearNow = 0 Or nLeapYearOfBillYear = 0 Then
nTotalDays = 90
Else
nTotalDays = 90
End If
If dtDiff > nTotalDays Then
For Each frmControl In Form_frmAccountStatus
If TypeOf frmControl Is TextBox Then
frmControl.Locked = True
End If
Next
For Each frmControl In Form_frmAccountStatus
If TypeOf frmControl Is ComboBox Then
frmControl.Locked = True
End If
Next
Me.tbPaidAmount.Enabled = False
bLockFlag = True
Else
For Each frmControl In Form_frmAccountStatus
If TypeOf frmControl Is TextBox Then
frmControl.Locked = False
End If
Next
For Each frmControl In Form_frmAccountStatus
If TypeOf frmControl Is ComboBox Then
frmControl.Locked = False
End If
Next
Me.tbPaidAmount.Enabled = True
End If
End Sub
Klatuu said:
Not quite. It has nothing to do with Null and the Locked logic is
backwards and would always be wrong.
In the Current event of the form...
With tblPaidAmount
.Enabled = [tbBillDate] < DateAdd("m",-3,Date)
.Locked = Not .Enabled
End With
How do I go about locking Records more than 3 Months old, I do have a
[tbBillDate] text box on my form, I am trying to lock [tbPaidAmont] if
[tbBillDate] is more than 3 Months Old !
In the Current event of the form...
tblPaidAmount.Enabled = not IsNull([tbBillDate])
tbPaidAmount.Locked= not IsNull([tbBillDate])