Locking some records in a form

Ste4en

Registered User.
Local time
Today, 20:45
Joined
Sep 19, 2001
Messages
142
I can't seem to find any answers to this maybe i am asking the wrong question, or its so easy nobody asked.

I am viewing / editing some records in a form, I want to view all of the records but only allow edits to records with forms with tblData.Locked = false.

How do I achieve this.

thanks

Steve
 
On each record change, could you not test for that and set or reset Allow Edits for the form?
 
I see "On Current" on the event Tab. Maybe an event procedure on that would change Allow edits to "No" when tblData.Locked = false.......But I don't know how to write that in VBA?..well I tried but it does not work..any help appreciated.

Code:
Private Sub Form_Current()

frm = frmRPAhdr

If tbl.rpahdr.Locked = False Then
        With frm
            .AllowEdits = True
        End With
    Else
        With frm
            .AllowEdits = False
        End With
    End If
End Sub
 
Try using the ME. object instead.

Might be easier than we think. have you tried
Me.AllowEdits = Not (whatever you are checking)

Since you want AllowEdits to be the reverse of what ever it is you are checking, and they are both booleans using NOT should give you what you want.
 
Last edited:
Well I fiddled about some more. This code locks all the records, somehow I need to add something that will tell it to just lock the records to be locked.

Can you spot the mistake??

Thanks


Code:
Private Sub Form_Current()

Dim frmrpahdr As Object
Dim rs As Object

If Me.Locked = False Then
        
            Me.AllowEdits = Yes
          Else
            Me.AllowEdits = No
            
End If
End Sub
 
Ok, I created a similar enviorment here, and copied your code, and it was always returning FALSE for some reason.
I changed it like this, and it works OK now for me.
Code:
If Not Me.Locked Then
        
            Me.AllowEdits = True
          Else
            Me.AllowEdits = False
            
End If
 

Users who are viewing this thread

Back
Top Bottom