473,407 Members | 2,598 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,407 software developers and data experts.

Lock From Problem

I have an option group on my form to toggle the controls' Locked
property. Somehow I'm also locking the "Unlock" button, but I'm not
sure why. Here's my code:

Public Sub LockForm()
On Error Resume Next

Dim frm As Form, i As Integer
Dim ctl As Control

i = Forms.Count - 1
Set frm = Forms(i)

For Each ctl In frm.Controls
ctl.Locked = True
Next ctl
frm.fraLocked.Locked = False
End Sub

Any advice would be greatly appreciated. Thanks.

Nov 13 '05 #1
4 1899
Well, I see a couple of problems if this is the full code.

1)
i = Forms.Count - 1
Set frm = Forms(i) You will always be doing this to the last form opened, the one with the
highest index number, is that what you want?

2) For Each ctl In frm.Controls
ctl.Locked = True
Next ctl
frm.fraLocked.Locked = False
End Sub
You are locking every control on the form (including buttons) then unlocking
fraLocked. You will need to unlock the Unlock button the same way or you
could use an If statement in the loop to keep from locking it in the first
place.

Example:
For Each ctl In frm.Controls
If ctl.Name<>"cmdMyButton" Then
ctl.Locked = True
End If
Next ctl
frm.fraLocked.Locked = False
End Sub
--
Wayne Morgan
MS Access MVP
"eliffman" <el******@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...I have an option group on my form to toggle the controls' Locked
property. Somehow I'm also locking the "Unlock" button, but I'm not
sure why. Here's my code:

Public Sub LockForm()
On Error Resume Next

Dim frm As Form, i As Integer
Dim ctl As Control

i = Forms.Count - 1
Set frm = Forms(i)

For Each ctl In frm.Controls
ctl.Locked = True
Next ctl
frm.fraLocked.Locked = False
End Sub

Any advice would be greatly appreciated. Thanks.

Nov 13 '05 #2
PS.

Rather than locking every control on the form, would it be easier to set the
form's AllowEdits, AllowAdditions, and AllowDeletions properties to False?
Since you're unlocking the frame, this may not work because it may lock the
frame for you also.

--
Wayne Morgan
MS Access MVP
Nov 13 '05 #3
I originally tried it that way, but I was getting inconsistent results
with the subforms and several of the forms have "find record" combo
boxes that need to stay active.

Shouldn't explicity unlocking the frame also unlock the toggle buttons
("Locked" & "Unlocked") inside it?

Nov 13 '05 #4
....Apparently not. I modified the code to unlock the frame and the
toggle button. Now it works.

Public Sub LockForm()
On Error Resume Next

Dim frm As Form, i As Integer
Dim ctl As Control

i = Forms.Count - 1
Set frm = Forms(i)

For Each ctl In frm.Controls
If ctl.Name <> "fraLocked" And ctl.Name <> "tglUnlocked" Then
ctl.Locked = True
End If
Next ctl
End Sub

Thanks for your help, Wayne.

Nov 13 '05 #5

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

Similar topics

1
by: xixi | last post by:
hi, we are using db2 udb v8.1 ESE with type 4 jcc driver. since DB2 can't support pessimistic locking , and our application required that, which means when both users try to access the same record...
6
by: Matias Woloski | last post by:
I have the following code which is running in every Page_Load of my ASP.Net app. It basically will add rows to a table upto MAX_CACHED_ITEMS and then will flush all the cached items to the...
2
by: rbutch | last post by:
hey guys - any insight into why a web application works fine with access, when i'm developing it and using local host. yet, when deploying it on a remote machine, access has a variety of complaints...
3
by: laststubborn | last post by:
Dear Memebers, I have a critical problem. I have an application is running on 64 bit machine. It used to be running on 32 bit machine. That application is using a Stored Procedure that uses...
8
by: Ritesh Raj Sarraf | last post by:
Hi, I think there is some lock problem. Let me show the code first import os import sys import string import tempfile
0
by: Shailja | last post by:
hello, I want to lock particular cell of VSFlexGrid. How to do that? I want to lock cell (Row1, Column 2). Kindly let me know if u know the answer
0
by: Matt | last post by:
Hi All, I have a databse that runs queries against an ODBC source throughout the day and night. I am having an issue where a query will run at night and throw an error message about not being...
1
archulu
by: archulu | last post by:
hai i want to use lock function in my project to lock the database table when i am pressing a button in front_end. at simultaniouly (online) another one press the button the request wait untill...
1
by: ray2heavy | last post by:
Hey guys, I am getting a "database cant lock table "blah" because it is already in use by another person or process" while trying to delete, then re-populate it. This table is viewed in a subform...
0
by: John Roberts | last post by:
Hi guys, My database is accessed by several users. When the user opens my report it first makes a table of temporary data from one query, then uses another query on that table to populate my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.