By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,489 Members | 1,945 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,489 IT Pros & Developers. It's quick & easy.

way to LOCK a textbox after data goes in

P: n/a
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)

Jun 7 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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...@yahoo.comwrote:
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)

Jun 7 '07 #2

P: n/a

"James" <ja******************@yahoo.co.ukwrote in message
news:11**********************@p47g2000hsd.googlegr oups.com...
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...@yahoo.comwrote:
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.
Jun 7 '07 #3

P: n/a
On Jun 7, 11:36 am, "paii, Ron" <p...@pack.comwrote:
"James" <james_no_spam_ple...@yahoo.co.ukwrote in message

news:11**********************@p47g2000hsd.googlegr oups.com...
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...@yahoo.comwrote:
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

Jun 7 '07 #4

P: n/a
In article <11**********************@p47g2000hsd.googlegroups .com>,
ca***************@yahoo.com says...
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)


Shouldnt ever have to have it 'unlocked' if its populated by a button
click. Click the button and set the field value by code. End of story.
never give the user the right to directly enter data in the text box to
begin with.
Jun 13 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.