Solved Disable Subform except First Record

mfaisal.ce

Member
Local time
Tomorrow, 00:20
Joined
Dec 21, 2020
Messages
76
Dear Friends,

Is there any way to Disable Subform except First Record or First Row......

Kindly guide....
 
Not really. The only thing I could think of is to use the Current event of the subform to check if the record pointer is on the first record. You can then enable or disable the controls based on that.
 
A better approach is probably to proactively design a way to filter the subform to the only record you really want to show, rather than showing extras, then trying to get away from them
 
I agree with Isaac not very user friendly, but this can be done pretty well.

Then select all controls
In the tag property put "locked"
In the On enter event put
=LockControls()
Code:
Public Function LockControls()
  Dim ctrl As Access.Control
  For Each ctrl In Me.Controls
    If ctrl.Tag = "Locked" Then
     ctrl.Locked = (Me.Recordset.AbsolutePosition <> 0)
    End If
  Next ctrl
End Function
 
You could also do this
Code:
Public Function LockControls()
  Dim ctrl As Access.Control
  For Each ctrl In Me.Controls
    If ctrl.Tag = "Locked" Then
     ctrl.Enabled = (Me.Recordset.AbsolutePosition = 0)
    End If
  Next ctrl
End Function
But then you have to use record selectors or navigation controls to move to the first record.
 
Dear All,
Maybe i am not able to elaborate my concern properly.... i will repeat,
I have Sales Detail Subform and Sales Payment subform...
At each new record in Sales Detail, it calculates and updates the Sales Payment but if user will Enter into Sales Payment subform and click on Row 2 and then add new record in Sales Detail. at this point when user will enter into sales payment form, it will be duplicated value in sales payment.... so, there i want to lock the whole Sales Payment Subform execpt First Row/Record....
 

Attachments

  • Untitled.jpg
    Untitled.jpg
    103.4 KB · Views: 111
  • Faisal.accdb
    Faisal.accdb
    1.7 MB · Views: 120
I think as I pointed out this can be solved by setting allow additions = false.
 

Users who are viewing this thread

Back
Top Bottom