I am currently producing a database to check the problems we have with parts are my work. I have set up an input form and linked tables to it. I have 6 areas on my sheet I want to lock when I click on a checkbox at the side of my form. One checkbox needs to lock three fields of information. I am currently using this code in VBA to lock the fields:
The problem I am having is that when I click on the checkbox it locks the fields on ALL records, I am looking for a way to fix this code to be record specific
P.S. I have a field at the top of the form called "ProblemNo", I was wondering if this could be used as it is connected to my main table and is the "Serial Number" of the problem I am currently looking at...
Thanks in Advance
/Sandy
First off, there is no need to have the same code for each checkbox appear in the OnClick event and the AfterUpdate event. One or the other will do!
Secondly, because you're apparently (from your description) doing this on a Continuous or Datasheet View Form, you need to use, for each appropriate control Me.PRAWhat3.Enabled = False
Me.PRAWhat3.Locked = True
or Me.PRAWhat3.Enabled = True
Me.PRAWhat3.Locked = False
in order for the formatting not to be obvious on all records, as setting the Enabled Property alone will. Using this combination "locks" the control, but doesn't "gray" it out.
Finally, in order for the formatting, i.e. the "locking" of the record to be record-specific, you need to include this code in the Form_Current event.
In this way, if you move to a record, the corresponding fields will be "locked" or not depending on its checkbox.
Welcome to Bytes!
Linq ;0)> 4 2109
First off, there is no need to have the same code for each checkbox appear in the OnClick event and the AfterUpdate event. One or the other will do!
Secondly, because you're apparently (from your description) doing this on a Continuous or Datasheet View Form, you need to use, for each appropriate control Me.PRAWhat3.Enabled = False
Me.PRAWhat3.Locked = True
or Me.PRAWhat3.Enabled = True
Me.PRAWhat3.Locked = False
in order for the formatting not to be obvious on all records, as setting the Enabled Property alone will. Using this combination "locks" the control, but doesn't "gray" it out.
Finally, in order for the formatting, i.e. the "locking" of the record to be record-specific, you need to include this code in the Form_Current event.
In this way, if you move to a record, the corresponding fields will be "locked" or not depending on its checkbox.
Welcome to Bytes!
Linq ;0)> NeoPa 32,556
Expert Mod 16PB
As Linq implied, the controls' attributes don't change per record, they change globally. That is to say there is only one control (for each) whose attributes are the same wherever it is seen on the form (See Why Values in Unbound Form Controls do not Persist). That is why you should follow Linq's advice about running the code in the Form_Current() event procedure too.
Because of this it is a good idea to have the code itself in separate procedures, and invoke them from the various event procedures where they are appropriate.
I would also consider shortening the code as there is little need for so many lines when it can be put more succinctly, without any loss of clarity (readability). As an example I'll post the code for one control : - Private Sub Form_Current()
-
Call Handle1(Me.Complete1)
-
Call Handle2(Me.Complete2)
-
...
-
End Sub
-
-
Private Sub Complete1_AfterUpdate()
-
Call Handle1(Me.Complete1)
-
End Sub
-
-
Private Sub Complete2_AfterUpdate()
-
Call Handle1(Me.Complete2)
-
End Sub
-
-
...
-
-
Private Sub Handle1(ByVal blnComplete As Boolean)
-
Me.IFAWhat1.Enabled = (blnComplete = False)
-
Me.IFAWho1.Enabled = (blnComplete = False)
-
Me.IFAWhen1.Enabled = (blnComplete = False)
-
End Sub
-
-
Private Sub Handle2(ByVal blnComplete As Boolean)
-
Me.IFAWhat2.Enabled = (blnComplete = False)
-
Me.IFAWho2.Enabled = (blnComplete = False)
-
Me.IFAWhen2.Enabled = (blnComplete = False)
-
End Sub
-
-
...
Thanks very much to both of you...This method works a treat and my database is now fully funtioning... Can't thenk you enough.
/Sandy
NeoPa 32,556
Expert Mod 16PB
Always a pleasure Sandy :)
I'll set the Best Answer for you.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ryan |
last post by:
I have a problem with record locking / blocking within an application.
The app is quite straight forward. Written in Delphi 5 using BDE to
access a SQL 7 database (Win2K server).
Every so often...
|
by: ethanj /personal/ |
last post by:
We are using Access 2000 database, with the following settings.
Tool > Options > Advance >
Default Record Locking = Edited Record
Open databases using record level locking = True
Form...
|
by: MS |
last post by:
Access 97 here.
I want a simple way to "lock" certain records on a form. Some records remain
"live" until all data is available which happens over time. When all the
fields are complete, I want...
|
by: brijeshmathew |
last post by:
Hi
I use Visual Basic 6, Service Pack 6, Microsoft ActiveX Data Objects
2.8 Library(msado15.dll) and access 2000 database using JET 4 OLE. I
have an application that adds records simultaneously...
|
by: pj |
last post by:
We are experiencing record locking errors which don't make sense.
O/S :Windows 2003 Server running Terminal Services
Access 2003 SP1
Front end copied to each user folder.
4 users adding...
|
by: paulwilliamsonremove |
last post by:
Hi,
Using Access 2003.
I am trying to delete records from one table/query
("qryHistoryPersonIDs") if they don't exist in another table
("qryDonations"). But the SQL syntax I came up with is...
|
by: Trees |
last post by:
I have a database that was created so that 4 separate shops could go
in and enter pertinent information about how their shops ran
throughout the day so that my boss (and theirs) could report out...
|
by: ABrown |
last post by:
Hello,
I have a 2003 database set up with about 20 users (only about 4 at a time) but I repeatedly get a problem with the records all locking. Each User is assigning billing codes to jobs so they...
|
by: tbeers |
last post by:
Good afternoon.
I am ready to deploy a database using access 2007. Been pretty happy with the development process. However, the application will be used over a terminal server network...windows...
|
by: kstevens |
last post by:
I have turned on record locking do to the fact that we are starting to have issues with the records not being locked. I have a button on a form that changes the recordsource of the form. When i...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |