Locking Certain Fields on a Form with a Table. (1 Viewer)

Loup

New member
Local time
Today, 22:35
Joined
May 1, 2017
Messages
6
Hi All

What I am trying to do, is use a form to display a table and then using that form only allow certain fields to be edited; this would apply to all records.

I would really appreciate some help
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 08:05
Joined
Feb 28, 2001
Messages
27,140
If the form in question is never going to be allowed to update those fields (perhaps because they originate elsewhere), just lock them by setting the .Locked property to True while that form is in Design View.

Your question seems so simple that I wonder if you didn't tell us everything about the problem. If you want the fields to be no-edit but not always, you need to specify how and when you will want changes to be allowed.
 

Loup

New member
Local time
Today, 22:35
Joined
May 1, 2017
Messages
6
Thanks for the reply

Ok say you have 10 fields in a table, you want to display this table on a form so that when the user opens it, that's all they see, then also suppose you want them to be able to update 5 of those 10 fields but not the other ones. That is what I am trying to do. I already know how to lock everything but I do not want to do that.:banghead:
 

Loup

New member
Local time
Today, 22:35
Joined
May 1, 2017
Messages
6
Thanks, Bob I only cross posted because on the other forum no one could understand what I was trying to do. Fresh eyes often have a fresh perspective so I will continue to do this in the future if required. That Micron individual seemed to want to split hairs and blame me for him not knowing how to solve the problem, either someone helps because they want to, or they don't it is entirely up to them, I would rather people with patience who genuinely want to share their expertise help me.
 

missinglinq

AWF VIP
Local time
Today, 09:05
Joined
Jun 20, 2003
Messages
6,423
To only Lock some of the Controls...in Form Design View

  1. Hold down <Shift> and Left Click on each Control in turn, that you want to Lock.
  2. Go to Properties Pane
  3. Click on Data Tab
  4. Change Locked Property to Yes
You're done!

Linq ;0)>
 

Frothingslosh

Premier Pale Stale Ale
Local time
Today, 09:05
Joined
Oct 17, 2012
Messages
3,276
Thanks, Bob I only cross posted because on the other forum no one could understand what I was trying to do. Fresh eyes often have a fresh perspective so I will continue to do this in the future if required. That Micron individual seemed to want to split hairs and blame me for him not knowing how to solve the problem, either someone helps because they want to, or they don't it is entirely up to them, I would rather people with patience who genuinely want to share their expertise help me.

The point wasn't that you cross-posted, but rather that you cross-posted without telling anyone.

Please read the second link Bob provided to learn why cross-posting is actually counter-productive.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 08:05
Joined
Feb 28, 2001
Messages
27,140
OK, I'll bite (and be patient).

I already know how to lock everything but I do not want to do that

Why do you not want to statically lock the fields in question? Your answer will tell us what we need to know to provide any alternative answer. The reason we are giving you the "lock it in design view" answer is because we don't understand why that is not acceptable to you. Stated another way, what else is going on to make the simplest answer not the right answer for you?
 

Loup

New member
Local time
Today, 22:35
Joined
May 1, 2017
Messages
6
I only want to lock some of the fields because there is information I do not want to be altered inadvertently. After the table on the form is set up correctly I will then set it to open in form view and not in design mode.
 

bob fitz

AWF VIP
Local time
Today, 14:05
Joined
May 23, 2011
Messages
4,719
Thanks, Bob I only cross posted because on the other forum no one could understand what I was trying to do.
Actually both Micron and myself understood perfectly what you required.
Fresh eyes often have a fresh perspective so I will continue to do this in the future if required.
I would agree that "fresh eyes often have a fresh perspective" and if you continue to cross-post in the future without referencing your other posts then I hope you get the response that the link I posted suggests is a possibility. I know that's what I'll be doing !
That Micron individual seemed to want to split hairs and blame me for him not knowing how to solve the problem, either someone helps because they want to, or they don't it is entirely up to them, I would rather people with patience who genuinely want to share their expertise help me.
I consider your remarks to be highly disingenuous. "That Micron individual" is actually a much respected member of the other forum who has been kind enough to patiently help hundreds of other members for many years past.

Questions that Micron asked were not answered and both Micron and myself suggested you post your db so that we could do it for you. If that's not the epitome of trying to be helpful, then I don't know what is. Progress in this forum seems to be reflecting what happened in the other post. Twenty nine posts. Much time wasted. No resolution.

Good luck with your project. I fear you will need it !
 

Loup

New member
Local time
Today, 22:35
Joined
May 1, 2017
Messages
6
Thanks everyone and apologies I haven't been at my desk today so I haven't been able to post my db.
 

Loup

New member
Local time
Today, 22:35
Joined
May 1, 2017
Messages
6
Ok so on Form 1 of the attached db, I would like it so the user can edit all the fields but "number"
 

Attachments

  • Test_db.accdb
    1.8 MB · Views: 80

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 08:05
Joined
Feb 28, 2001
Messages
27,140
Loup - you still have not given an adequate answer to WHY we cannot simply lock the fields involved using the properties of the control. You are not telling us something and that is why we are having the issue. Do not tell us it is our fault that you didn't tell us everything we needed to know as to WHY control locking isn't the answer you need. Tell us what ELSE is going on. Otherwise you are going to continue to get the same kind of answer you have been getting already.
 

GinaWhipp

AWF VIP
Local time
Today, 09:05
Joined
Jun 21, 2011
Messages
5,900
Perhaps this will help...

Code:
Function ImLocked(frm As Form, LockIt As Boolean) As Boolean
    'Lock or unlock all data-bound controls on form,
    'depending on the value of <LockIt>: True = lock; False = unlock.
    'Dirk Goldgar 2005
    '2012 rtw modified to lock specific controls
    
    On Error GoTo Err_ImLocked
    Const conERR_NO_PROPERTY = 438
    
    Dim ctl As Control
       
    For Each ctl In frm.Controls
        With ctl
            If Left(.ControlSource & "=", 1) <> "=" Then
                If ctl.Tag = "locked" Then
                  .Locked = LockIt
                  .Enabled = True
               End If
            End If
        End With
Skip_Control:       'come here from error if no .ControlSource property
    Next ctl
Exit_ImLocked:
    Exit Function
    
Err_ImLocked:
    If Err.Number = conERR_NO_PROPERTY Then
        Resume Skip_Control
    Else
        MsgBox "Error " & Err.Number & ": " & Err.Description
        Resume Exit_ImLocked
    End If
 End Function

Just add the work locked to the Tag property of the control. Note, this works with bound controls.
 

Users who are viewing this thread

Top Bottom