473,386 Members | 1,846 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.

Change field 'Locked' property in VBA

Hi,
I have a database which is used by multiple users. They access it via a login screen and then via a main form. The main form displays a table. When certain users log in, I want them to be able to edit a specific field, whereas when other users log in I want them to have read only access to the field.
What do I need to write in the VBA when the user logs in to amend the 'Locked' property of the field? (assuming this is the right/best solution)


Any help would be much appreciated!

Thanks
Ryan
Mar 7 '11 #1
4 6389
NeoPa
32,556 Expert Mod 16PB
The control (not field) that displays the data you want to control has a .Locked property that you set depending on the value of the username used.
Mar 7 '11 #2
Thanks for replying. So what would I write in the VBA code... something like

Expand|Select|Wrap|Line Numbers
  1. If username = "Bob" Then
  2. Set rst_tbl = dbsDB.Openrecordset"tblMainData")
  3.     With rst_tbl
  4.         !Field.Locked = TRUE
  5.     End with
  6. Else End If
Mar 7 '11 #3
TheSmileyCoder
2,322 Expert Mod 2GB
As NeoPa said, the CONTROL which is for example a textbox on your FORM can be locked. The field(column) of a table cannot be locked.
Mar 7 '11 #4
NeoPa
32,556 Expert Mod 16PB
As Smiley says, you'd set the .Locked property of the other control on the current form, according to the value found in the Me.UserName control.

The code might be something like :
Expand|Select|Wrap|Line Numbers
  1. Private Const conValid As String = ",Bob,Admin,Administrator,"
  2.  
  3. Private Sub UserName_AfterUpdate()
  4.     With Me
  5.         .ManagedControl.Locked = Not (InStr(1, _
  6.                                             conValid, _
  7.                                             "," & .UserName & ",") > 0)
  8.     End With
  9. End Sub
Mar 7 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Finn | last post by:
What has happened to a control's .Locked property ? Has Microsoft removed it ? The textbox control has a .ReadOnly property, but other controls (such as the combo) do not have this property. ...
0
by: Tech | last post by:
In Visual Basic 6.0, the Locked property of a ComboBox control determined whether the text-box portion of the control could be edited. In Visual Basic ..NET, the Locked property prevents a control...
1
by: windandwaves | last post by:
Hi Folk I am working with the TYPE property. I want to change that from 2 (byte) to 4 (long integer) for a field that already contains tons of data. How can I do that? The help reads: ...
2
by: David L Wright II | last post by:
In VB6, any column in the DataGrid had a Locked Property. I can not find this property in the .Net DataGrid. Where is this property or what is the replacement property?
7
by: Andrea Moro | last post by:
I'm writing my first windows control library. A simple textbox with some numeric facilities. Well, there is a strange thing that happen. I want to add a locked property. As many other property,...
3
by: Arsalan | last post by:
What is the equivalent of VB6.0 locked property in VB.NET ? How do I make uneditable textbox
0
by: Evan Camilleri | last post by:
I want to create a combox locked property. Similar to Enabled=False BUT I do NOT want the control to be grayed out. Evan
0
by: cmrhema | last post by:
Hello I used to write the code text1.locked=true but to my utter surprise i could not find it in vb 2005 the locked property is displayed in property box but when i put down the code it does not...
6
by: ljstern | last post by:
Hello. I am using MS Access 2003 with XP/pro. I have a form that has the following properties set through the property sheet: form: AllowAdditions = False CartridgeID field: Locked = True ...
5
by: opmandrake | last post by:
Evening guys. Here something that's been driving me nuts for the past couple of hours. I have a mainform and in it, two subforms. Normally I'd like the fields to be read-only, but if a user has...
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:
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...
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.