473,386 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Locking a Field after a box is ticked

Hi.

I am currently working on a form that I need to prevent changes to
after data has been input.

There are a series of tick boxes on the form, and when each one of
these is ticked it spawns the current date and time in another field. I
want the form to then lock both the tick box and the field that now has
the date in it, so that it can no longer be unticked or the date
manually altered.

I have tried using the following code to do this, and it does lock the
fields after the tick box has been used, but it also locks all the
other tick boxes that also have the same code attached to them. I
obviously want the locking to be independant, so that the locking of
one set doesn't affect the others. The code I have tried to use is
here, and is attached to each of the tick boxes.

Private Sub
Screen.ActiveControl.Locked = Not IsNull(ScreenActiveControl)
End Sub

Does anybody know what / where I am going wrong?

Thanks

Nov 13 '05 #1
5 1821

Try this

Private Sub
Screen.ActiveControl.enabled= False
End Sub

Madhivanan

Nov 13 '05 #2
ja******@gmail.com wrote:
There are a series of tick boxes on the form, and when each one of
these is ticked it spawns the current date and time in another field. I
want the form to then lock both the tick box and the field that now has
the date in it, so that it can no longer be unticked or the date
manually altered.


Try something like this in your *form's* After Update event (untested):

If Me.MyCheckBox = -1 Then
Me.chkMyCheckBox.Enabled = False
Me.txtMyTextBox.Enabled = False
Else
Me.chkMyCheckBox.Enabled = True
Me.txtMyTextBox.Enabled = True
End If

You'd also need this in your form's On Current event so that the check box
is tested as you navigate between records. There might be a more elegant
way to do it but this should work for starters.

Regards,
Keith.
www.keithwilby.com
Nov 13 '05 #3
I have managed to get the form to lock the correct fields now thanks. I
now have another problem in that when I close the form and reopen it
the fields are again unlocked, till I click on them again, after which
they are locked again.

The code I am using is as follows

Private Sub InstallDateRequested_YN_Click()
If Me.InstallDateRequested_YN = True Then
InstallDateRequested = Now()
InstallDateRequested.Locked = True
InstallDateRequested_YN.Locked = True
End If
End Sub

I have also tried

Private Sub InstallDateRequested_YN_AfterUpdates()
If Me.InstallDateRequested_YN = True Then
InstallDateRequested = Now()
InstallDateRequested.Locked = True
InstallDateRequested_YN.Locked = True
End If
End Sub

Any ideas?

Nov 13 '05 #4
ja******@gmail.com wrote:

Any ideas?


Re-read my first response. You need to use the *FORM'S* After Update and On
Current events. Using the control's click and update events as you have
will only do what you want for the current record.
Nov 13 '05 #5
ja******@gmail.com wrote:
Any ideas?


Re-read my first response. You need to use the *FORM'S* After Update and On
Current events. Using the control's click and update events as you have
will only do what you want for the current record.
Nov 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Nid | last post by:
How do I do row-level locking on SQL Server? Thanks, Nid
2
by: spammy | last post by:
hi all, im trying to establish whether i have a race condition or critical section in the following. i have a dataaccess class that continually retireves a table from a sqlserver (which may be...
1
by: Justin | last post by:
Hello: I have a question regarding Record Locking in ASP...If the user x's out of the web page, how can I unlock the record? A co-worker told me it has to be done in Javascript, but he doesn't...
1
by: Manton | last post by:
Hi. I'd like to know if after the records have been ticked , whether one can then have those same records unticked - in case a mistake had been made the first time to tick them....
4
by: andrewbda | last post by:
I have tickbox on a form, and I would like to use a date field as the control source. i.e. I would like to have it display as ticked when a date exists in the field, and vice versa. Also,...
2
by: David - Australia | last post by:
G'day from Australia, I'm hoping some bright spark may be able to help me with this one. I'm sure that it can be done, I've just hit a wall with it. So I'm opening it up. I'm storing student...
0
by: xpding | last post by:
Hello, I have a class MyEmbededList contains a generic dictionary, the value field is actually the MyEmbededList type as well. There is another class need to access and manipulate a list of...
3
by: David C. Barber | last post by:
How do you lock a record in SQL Server from ASP 2? I need to read the record, allow the user to edit it, and then have them click Save and rewrite it. Obviously I don't want anyone else getting...
1
by: Paul H | last post by:
I have an Employees table with the following fields: EmployeeID SupervisorID Fred Bob Bob John Bob Mary Bill Bill I have created a self join in...
0
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.