473,385 Members | 1,325 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,385 software developers and data experts.

Locking controls on a form

EJO
TIA!

I have an A2k mdb which contains a sample record so that my users can
have an online example of input for a any given field. I don't want
them to be able to edit the record, but also do not want to prevent
them from doing a lookup for the live data, so using the allowedits
property doesn't seem to be an option. Is there a way to lock all the
controls without listing the over 60 controls individually, then unlock
the lookup? I tried to use the enumerate controls from the access web
faq, but haven't been able to modify for this purpose.

Nov 13 '05 #1
4 1538
"EJO" <5p****@centurytel.net> wrote:
Is there a way to lock all the
controls without listing the over 60 controls individually, then unlock
the lookup? I tried to use the enumerate controls from the access web
faq, but haven't been able to modify for this purpose.


This will lock all text boxes, combo boxes, check boxes and option groups:

Dim ctl As Control
For Each ctl In Me.Controls
If TypeOf ctl Is TextBox Or TypeOf ctl Is CheckBox Or TypeOf ctl Is
ComboBox Or TypeOf ctl Is OptionGroup Then
ctl.Locked = True
End If
Next

I'm not sure this is the best solution to your problem, I think you'd need
to post more info.

Regards,
Keith.
www.keithwilby.com
Nov 13 '05 #2
> I have an A2k mdb which contains a sample record so that my users can
have an online example of input for a any given field. I don't want
them to be able to edit the record, but also do not want to prevent
them from doing a lookup for the live data, so using the allowedits
property doesn't seem to be an option. Is there a way to lock all the
controls without listing the over 60 controls individually, then unlock
the lookup? I tried to use the enumerate controls from the access web
faq, but haven't been able to modify for this purpose.


If you name your controls with a number suffix (the one you want to lock),
you could put them in a loop. I've done this on occasion.

Private sub LockControls(blnLock as boolean)
Dim ctl as control
For each ctl in Me.Controls
If IsNumeric(Right(ctl.name, 2)) Then ctl.Locked = blnLock
Next
End sub

You could do stuff with different number ranges - like enable or disable.
you might have to check the syntax of my example, but you get the idea...
Nov 13 '05 #3
EJO
actually, this worked great. thanks for the help!

Nov 13 '05 #4
Maybe just use a 'snapshot' for the forms recordsource and your form will be read-only .
I don't understand what you mean by 'doing a lookup'.
--
Hope this helps
Arno R
"EJO" <5p****@centurytel.net> schreef in bericht
news:11**********************@o13g2000cwo.googlegr oups.com...
TIA!

I have an A2k mdb which contains a sample record so that my users can
have an online example of input for a any given field. I don't want
them to be able to edit the record, but also do not want to prevent
them from doing a lookup for the live data, so using the allowedits
property doesn't seem to be an option. Is there a way to lock all the
controls without listing the over 60 controls individually, then unlock
the lookup? I tried to use the enumerate controls from the access web
faq, but haven't been able to modify for this purpose.

Nov 13 '05 #5

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

Similar topics

6
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...
8
by: ken | last post by:
Hi, I have a form that depending on certain criteria locks all of the subforms on this form. The problem is when the code unlocks the subforms their "allowedits" "allowdeletions" and...
2
by: TechBoy | last post by:
I have 2 forms FrmMain and frmSearch. On frmMain I have to lock the textboxes and combo boxes on the form if the user logged out that record. FrmMain has a command button that launches...
3
by: crgsmrt | last post by:
Hi all, I'd really appreciate it if someone was able to help me out with a problem I'm having with C#. I'm a complete newbie to this, so please excuse what may appear as a stupid question. ...
10
by: Ami | last post by:
Hello everyone, I have developed a small access application and now I need to lock my forms against unwanted edits. I have used the code by Allen Browne I found here...
7
by: RichG | last post by:
I want to lock all controls except the buttons on a form. I sometimes need the form to call lockForms(Me). public sub lockControls(frm as form) for each ctrl as control in frm if...
1
by: Michael728 | last post by:
Need some help please. There are 4 tables in this database. Six controls on the form are related to the table Degree. The other controls on the form are related to the other three tables. My...
1
by: haroonahmad | last post by:
I would really like to have the form come up locked, and then the user unlock it for changes, and then lock it again. I'm using Access 2003. I have no idea how to do it, but have seen it. ...
1
by: tim2006 | last post by:
When i try to run the program, it just hangs. If i remove the axwebbrowser control it works fine. Any ideas? Here is my code: class1.vb Imports System.Windows.Forms Imports...
1
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...
0
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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: 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...

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.