> 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.
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.