Re: way to LOCK a textbox after data goes in



On Jun 7, 11:36 am, "paii, Ron" <p...@xxxxxxxx> wrote:
"James" <james_no_spam_ple...@xxxxxxxxxxx> wrote in message

news:1181228532.889142.260530@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx



Hi

You cannot change the visibility of something while it has the focus.
The fact you are clicking on btnEnd means it will have the focus,
instead add an extra line in your code to give something else the
focus such as:

Private Sub btnEnd_Click()
[Forms]![frmCustDetail]![frmTimeEntry]![txtCallEndTime] = Now()
SomeOtherControl.Setfocus
btnEnd.Visible = False
End Sub

Regards
James

On 7 Jun, 15:26, slinky <campbellbrian2...@xxxxxxxxx> wrote:
I have a textbox that a user enters the current time (in this case at
the end of a task, and it gets its value via a button's click event
and getting its value from =Now() ).
Is there a way to LOCK this textbox's value once the user hits the
button that posts the time. I tried to make the button invisibe right
after the button is hit, but I get an error.
Anyone got any clues for revision? Thanks! Here is my code:

Private Sub btnStart_Click()
[Forms]![frmCustDetail]![frmTimeEntry]![txtCallBeginTime] =
[Forms]![frmCustDetail]![frmTimeEntry]![txtNow]
End Sub
Private Sub btnEnd_Click()
[Forms]![frmCustDetail]![frmTimeEntry]![txtCallEndTime] = Now()
btnEnd.Visible = False
End Sub

(Note that the button for start gets its value from a textbox that
uses =Now(), and the End button simply gets a real =Now(). This all
works great up till the point that the user can change the end time by
hitting the End button again. My thoughts were to make it invisible
after hitting the button)

Assuming the button is no the same form as the text box, you can also
replace

[Forms]![frmCustDetail]![frmTimeEntry]![txtCallEndTime] = Now()

with

Me![txtCallEndTime] = Now()

Also add code to the OnCurrent event to show or hide the button depending on
the status of the text box.

....and if you still want to be able to be able to view the entered
value after it's been set, toggle the .Locked property instead instead
of the .Visible property:

If (Len(Me![txtCallEndTime]) > 0) then
Me.txtCallEndTime.Locked = True
Else
Me.txtCallEndTime.Locked = False
End If

Lucks!

Ron, King of Chi

.



Relevant Pages

  • Re: way to LOCK a textbox after data goes in
    ... Is there a way to LOCK this textbox's value once the user hits the ... I tried to make the button invisibe right ... Private Sub btnStart_Click ... hitting the End button again. ...
    (comp.databases.ms-access)
  • Re: way to LOCK a textbox after data goes in
    ... Is there a way to LOCK this textbox's value once the user hits the ... I tried to make the button invisibe right ... Private Sub btnStart_Click ... hitting the End button again. ...
    (comp.databases.ms-access)
  • Re: way to LOCK a textbox after data goes in
    ... Is there a way to LOCK this textbox's value once the user hits the ... I tried to make the button invisibe right ... Private Sub btnStart_Click ... hitting the End button again. ...
    (comp.databases.ms-access)
  • way to LOCK a textbox after data goes in
    ... I have a textbox that a user enters the current time (in this case at ... I tried to make the button invisibe right ... Private Sub btnStart_Click ... hitting the End button again. ...
    (comp.databases.ms-access)
  • Re: Protecting Fields
    ... In the Current event of the form, you could set the Locked property of the ... based on the NewRecord property of the form: ... Private Sub Form_Current ... rather than allenbrowne at mvps dot org. ...
    (microsoft.public.access.forms)