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 / Macros / December 2007

Tip: Looking for answers? Try searching our database.

Is there a way to make a field read-only after it has been written

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Doyman - 17 Dec 2007 19:38 GMT
In access 2003, I have a form that multiple users access.  I need to make a
certain field read only after the user has entered a unique number.  Can
someone help me figure out how to do this?
Thanks in advance.
Ken Snell (MVP) - 18 Dec 2007 01:00 GMT
By "field", may we assume that you mean a control (e.g., textbox) on a form?
If yes, you can lock the control after the user enters the unique data.

Signature

       Ken Snell
<MS ACCESS MVP>

> In access 2003, I have a form that multiple users access.  I need to make
> a
> certain field read only after the user has entered a unique number.  Can
> someone help me figure out how to do this?
> Thanks in advance.
Doyman - 18 Dec 2007 16:41 GMT
Yes a control.  BUT I'm to stupid to figure out how to do what you are
saying.  :(

> By "field", may we assume that you mean a control (e.g., textbox) on a form?
> If yes, you can lock the control after the user enters the unique data.
[quoted text clipped - 4 lines]
> > someone help me figure out how to do this?
> > Thanks in advance.
Ken Snell (MVP) - 19 Dec 2007 20:05 GMT
How are you identifying that an entered value is "unique"?

Signature

       Ken Snell
<MS ACCESS MVP>

> Yes a control.  BUT I'm to stupid to figure out how to do what you are
> saying.  :(
[quoted text clipped - 10 lines]
>> > someone help me figure out how to do this?
>> > Thanks in advance.
Doyman - 19 Dec 2007 21:02 GMT
The table that the form is based on has this control set to be indexed with
no duplicates.

> In access 2003, I have a form that multiple users access.  I need to make a
> certain field read only after the user has entered a unique number.  Can
> someone help me figure out how to do this?
> Thanks in advance.
Ken Snell (MVP) - 31 Dec 2007 18:20 GMT
Easiest way to do this is to use BeforeUpdate event of the control to run
some simple VBA code:

Private Sub NameOfControlBoundToField_BeforeUpdate(Cancel As Integer)
If DCount("*", "NameOfTable", "NameOfField=" &
Me.NameOfControlBoundToField.Value) _
   >0 Then
   MsgBox "Cannot enter a duplicate value!"
   Cancel = True
End If
End Sub
Signature


       Ken Snell
<MS ACCESS MVP>

> The table that the form is based on has this control set to be indexed
> with
[quoted text clipped - 5 lines]
>> someone help me figure out how to do this?
>> Thanks in advance.
Ken Snell (MVP) - 31 Dec 2007 18:41 GMT
Sorry - my suggestion isn't quite the solution that you're seeking.

You can lock a control based on the value in the control, using the form's
Current event:

Private Sub Form_Current()
Me.NameOfControlBoundToField.Locked = ( _
   DCount("*", "NameOfTable", "NameOfField=" & _
   Me.NameOfControlBoundToField.Value) >0)
End Sub

This can be done by a macro instead of VBA programming:

   Action:  SetValue
       Item:  NameOfControlBoundToField.Locked
       Expression:  DCount("*", "NameOfTable", "NameOfField=" &
NameOfControlBoundToField.Value) > 0)

Signature

       Ken Snell
<MS ACCESS MVP>

> Easiest way to do this is to use BeforeUpdate event of the control to run
> some simple VBA code:
[quoted text clipped - 16 lines]
>>> someone help me figure out how to do this?
>>> Thanks in advance.
 
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.