How do I restrict editing but still allow access to headers and footers? (1 Viewer)

mtagliaferri

Registered User.
Local time
Today, 01:07
Joined
Jul 16, 2006
Messages
519
I have a form that displays data in 'Continuous Form' and the following settings in the property form, the record source is from a query:
- Data Entry = No
- Allow Additions = No
- Allow Deletions = No
- Allow Edits = No
- Allow Filters = Yes

This is perfect as when the form is opened there is no risk to erroneous alterations, the downside is that on the header of the form I have a nice search text box to fileter/search specific records, of course with the above settings I cant type in the search box!

Any solutions to deny any changes in the form but to have access to the search box?

the search box has the flowing code:
Code:
Private Sub CmdSearch_Click()
    Dim strSearch As String
    Dim strTxt As String
    strTxt = Me.TxtSearchBox.Value
    strSearch = "SELECT * from qryCrewMemberList where ((StaffNumber like ""*" & strTxt & "*"") or (Surname like ""*" & strTxt & "*"") or (FirstName like ""*" & strTxt & "*"") or (CallSign like ""*" & strTxt & "*"") )"
    Me.RecordSource = strSearch
    Me.RecordSource = Replace(strSearch, "{0}", Me.TxtSearchBox)
    Me.TxtSearchBox = ""
End Sub
 

Attachments

  • 1.PNG
    1.PNG
    11.3 KB · Views: 65

missinglinq

AWF VIP
Local time
Yesterday, 20:07
Joined
Jun 20, 2003
Messages
6,423
This type of situation requires that you Lock all Controls that you want inaccessible, rather than using the Form's Properties as you're now doing.

If you're talking about a fair number of Controls being Locked/Unlocked, you may want to set the Tag Property of those to be manipulated to something, say 'Tagged,' (without the single quotes) then loop through all Controls and Lock or Unlock all Controls that you've 'tagged,' as appropriate.

Linq ;0)>
 

mtagliaferri

Registered User.
Local time
Today, 01:07
Joined
Jul 16, 2006
Messages
519
That sounds very complicated!!!
 

missinglinq

AWF VIP
Local time
Yesterday, 20:07
Joined
Jun 20, 2003
Messages
6,423
Not really:

In Form Design View

  • Hold down <Shift> and Click on the Controls to be Looped, in order to select them
  • Right-Click then Click on Properties
  • Go to Other Tab
  • In the Tag Property enter Tagged (without Quotation Marks)

Now, to Lock the selected Controls, in an appropriate event

Code:
For Each ctl In Me.Controls
  If ctl.Tag = "Tagged" Then
    ctl.Locked = True
  End If
 Next
Now, to Unlock the selected Controls, in an appropriate event

Code:
For Each ctl In Me.Controls
  If ctl.Tag = "Tagged" Then
    ctl.Locked = False
  End If
Next

Linq ;0)>

Oops! Ridders got in ahead of me! Got distracted in mid-post by dog needing to go out! :D
 

CJ_London

Super Moderator
Staff member
Local time
Today, 01:07
Joined
Feb 19, 2013
Messages
16,663
another alternative is to create a new form - with allow edits=true. Move your buttons/searchboxes etc to the new form and include your existing form (with allow edits =false) as a subform
 

missinglinq

AWF VIP
Local time
Yesterday, 20:07
Joined
Jun 20, 2003
Messages
6,423
Glad we could help!

Good luck with your project!

Linq ;0)>
 

Users who are viewing this thread

Top Bottom