Solved

Filtering not allowed ..

Posted on 2011-03-09
5
369 Views
Last Modified: 2012-05-11
Hi,
See code below.
This was a very helpful response I got to an earlier query.
It prevents the user from changing data unless it is a new record.

Unfortunately, it is also preventing the user from filtering and or sorting this data.
Is it possible to prevent change but allow filter (preferably by using something similar to the code below?

Sub Form_Current()
  Me.YourControl.Enabled = Me.NewRecord
  Me.YourControl.Locked = Not Me.NewRecord
End Sub

Open in new window

0
Comment
Question by:Patrick O'Dea
  • 3
  • 2
5 Comments
 
LVL 75
ID: 35088957


Sub Form_Current()
  '  Me.YourControl.Enabled = Me.NewRecord     ' take this out - Enable the Control ... then just Lock it.
  Me.YourControl.Locked = Not Me.NewRecord
End Sub

mx
0
 

Author Comment

by:Patrick O'Dea
ID: 35089099
Sorry databaseMX,

I should have mentioned..

I need to be able to enter data for NEW records - therefore I cannot lock the control.

Background: I am setting up a supplier table.  I need to be able to add supplier codes.  However, once they are added they cannot be changed.  I do not want to use auto numbering.

When I open a continuous form of 1,000 suppliers I want to be able to filter on these codes (but NOT change them).
 
0
 
LVL 75
ID: 35089124
Are you talking about using the built in Right Click Sort / Filter options - on that Text box ?

mx
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 500 total points
ID: 35089153
"I need to be able to enter data for NEW records - therefore I cannot lock the control."

Well .. your original code still handles that

Sub Form_Current()
  '  Me.YourControl.Enabled = Me.NewRecord     ' take this out - Enable the Control ... then just Lock it.
  Me.YourControl.Locked = Not Me.NewRecord
End Sub

Not sure I see where the issues is ... ?  As long as the control is always Enabled, you can click into or over it ... and Right Click and Filter / Sort ...

mx
0
 

Author Closing Comment

by:Patrick O'Dea
ID: 35089364
All works fine now.

I am not 100% sure why but I will figure that out tomorrow.

Thanks again.
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question