Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / July 2005

Tip: Looking for answers? Try searching our database.

Lock a field

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sacredarms - 16 Jul 2005 06:23 GMT
I have a form based on a table that has a field where the user enters their
name from a drop down box. What I would like to do is after the user chooses
his/her name, the field locks out any changes. Is this possible and if so
where do I start?
Any help appreciated.

Joseph
Marshall Barton - 16 Jul 2005 06:37 GMT
>I have a form based on a table that has a field where the user enters their
>name from a drop down box. What I would like to do is after the user chooses
>his/her name, the field locks out any changes. Is this possible and if so
>where do I start?

You can use the combo box's AfterUpdate event procedure to
lock the  combo box:

    Me.comboboxname.Locked = Not IsNull(Me.comboboxname)

You should also have the same line of code in the form's
Current event so it can't be changed when they first
navigate to a different record or reopen the form later.

But, the AfterUpdate event doesn't allow a user to  make a
correction if they picked the wrong name.  Wouldn't it be
better to only lock it after they have finished with the
record?  If so, then only use the form's Current event to
run the line of code.

Signature

Marsh
MVP [MS Access]

sacredarms - 16 Jul 2005 07:43 GMT
Thanks for the help but I now get an error that reads "microsoft office
cannot find the macro named me:

> >I have a form based on a table that has a field where the user enters their
> >name from a drop down box. What I would like to do is after the user chooses
[quoted text clipped - 15 lines]
> record?  If so, then only use the form's Current event to
> run the line of code.
Marshall Barton - 16 Jul 2005 16:52 GMT
It sounds like you put the line of code in the AfterUpdate
event **property**, which should contain
[Event Procedure]

The code belongs in the combo box's AfterUpdate event
**procedure**  (in the form's module).  You can get to the
procedure by clicking on the [...] button over in the right
edge of the event property.
Signature

Marsh
MVP [MS Access]

>Thanks for the help but I now get an error that reads "microsoft office
>cannot find the macro named me:
[quoted text clipped - 18 lines]
>> record?  If so, then only use the form's Current event to
>> run the line of code.
sacredarms - 16 Jul 2005 07:45 GMT
Thanks for the help. I now get an eror that the macro named Me.

Thanks again
Joseph

> >I have a form based on a table that has a field where the user enters their
> >name from a drop down box. What I would like to do is after the user chooses
[quoted text clipped - 15 lines]
> record?  If so, then only use the form's Current event to
> run the line of code.
Ronald Roberts - 17 Jul 2005 05:44 GMT
When you create the AfterUpdate Event, you should select the expression
builder, not the macro builder.
The Line below is VBA code not a macro

Me.comboboxname.Locked = Not IsNull(Me.comboboxname)

Ron

> Thanks for the help. I now get an eror that the macro named Me.
>
[quoted text clipped - 20 lines]
>>record?  If so, then only use the form's Current event to
>>run the line of code.
Ronald Roberts - 17 Jul 2005 05:51 GMT
Sorry about that, It's code builder, not expression.

Ron

> When you create the AfterUpdate Event, you should select the expression
> builder, not the macro builder.
[quoted text clipped - 27 lines]
>>> record?  If so, then only use the form's Current event to
>>> run the line of code.
Ronald Roberts - 16 Jul 2005 06:56 GMT
In the AfterUpdate event of the Drop Down box you can do:
Me.ControlName.Locked = true
But, what if the user happens to click the wrong name by mistake.
How or what method are you going allow the user to use to unlock
the drop down box.

Ron

> I have a form based on a table that has a field where the user enters their
> name from a drop down box. What I would like to do is after the user chooses
[quoted text clipped - 3 lines]
>
> Joseph
sacredarms - 16 Jul 2005 15:29 GMT
I understand the question but I am not sure that I want the info allowed to
be changed unless I can track the changes.

> In the AfterUpdate event of the Drop Down box you can do:
> Me.ControlName.Locked = true
[quoted text clipped - 11 lines]
> >
> > Joseph
Ronald Roberts - 17 Jul 2005 05:55 GMT
You understand your application, I don't.  The point is, I can't
think of any reason why I would want to do this.  If it is for
security, there are other ways of doing what you want.  Maybe
if you would tell us what you want to do, others can help with a
better answer.

Ron

> I understand the question but I am not sure that I want the info allowed to
> be changed unless I can track the changes.
[quoted text clipped - 14 lines]
>>>
>>>Joseph
sacredarms - 18 Jul 2005 05:57 GMT
Hi again, I was just looking for the person who logged the event. I would
want to lock the field but I guess you're right. If someone does enter the
wrong information I would need them to correct it, so I will leave it as is.
Thanks
Joseph

> You understand your application, I don't.  The point is, I can't
> think of any reason why I would want to do this.  If it is for
[quoted text clipped - 22 lines]
> >>>
> >>>Joseph
kbanes - 18 Jul 2005 13:35 GMT
It sounds like you might want to do something like what I frequently use.

In most of my Access apps (which are very simple), I just want to know who
originally put in the record.  The easiest way to do this for me is to just
read their network ID, and record this in a field of the original record.  I
can link it back to a reference table that has all of their personal info
(phone, mail code, department).

It is easier to grab the names, but you create yourself some work by having
to maintain the personal data table.

There are probably many ways to capture the network ID, but I use the
following in the OnLoad of the new record form:

Private Sub Form_Load()
Dim strenv As String
strenv = UCase$(Environ$("USERNAME"))
Me![Preparer_ID] = strenv
End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.