Disable record edit of a subform

G

Guest

I have a form "SubjectA" and a subform in it "SubjectB"
Form "SubjectA" field are :
FormNo
Customer
Remarks

SubForm "SubjectB" fields are :
FormNo (its has a relationship with Parent Form and it is hidden on the form)
DateIn
Descrip
Amount


Now I want to disable any edit of the records of subform if the DateIn value
date is 15 days older than the current date.

Actually I want to stop user editing any record of subform it the dateIn is
old, and allow them to add records or edit records of subform if the DateIn
is less than 15 days old.

Please advise.
 
A

Allen Browne

1. Open the subform in design view.

2. In the Properties box (View menu), set the On Current property (Event tab
of Properties box) to:
[Event Procedure]
Click the Build button (...) beside this.
Access opens the code window.

3. Set up the Current event to look something like this:

Private Sub Form_Current()
Dim bBlock as Boolean

If DateDiff("d", Me.[DateIn], Date) >= 15 Then
bBlock = True
End If

Me.AllowEdits = Not bBlock
Me.AllowDeletions = Not bBlock
End Sub
 
G

Guest

Thanks Sir, It worked fine. Regards.

Allen Browne said:
1. Open the subform in design view.

2. In the Properties box (View menu), set the On Current property (Event tab
of Properties box) to:
[Event Procedure]
Click the Build button (...) beside this.
Access opens the code window.

3. Set up the Current event to look something like this:

Private Sub Form_Current()
Dim bBlock as Boolean

If DateDiff("d", Me.[DateIn], Date) >= 15 Then
bBlock = True
End If

Me.AllowEdits = Not bBlock
Me.AllowDeletions = Not bBlock
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Irshad Alam said:
I have a form "SubjectA" and a subform in it "SubjectB"
Form "SubjectA" field are :
FormNo
Customer
Remarks

SubForm "SubjectB" fields are :
FormNo (its has a relationship with Parent Form and it is hidden on the
form)
DateIn
Descrip
Amount


Now I want to disable any edit of the records of subform if the DateIn
value
date is 15 days older than the current date.

Actually I want to stop user editing any record of subform it the dateIn
is
old, and allow them to add records or edit records of subform if the
DateIn
is less than 15 days old.

Please advise.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top