SetFocus and Comments Box Behavior

  • Thread starter Thread starter Pamela via AccessMonster.com
  • Start date Start date
P

Pamela via AccessMonster.com

Hello,

I am developing a form with page breaks & subforms and am trying to do the
following:

In a subform, I have a comments box. When the user checks the "Other" check
box, I have the comments field highlighted & move the focus to the comments
box. When the user clears the "Other" check box, the comments box turns
white. If the user tried to exit the comments box without entering a
comment (when "Other" is checked), an alert pops up telling them to enter a
comment, & the focus returns to the comments box, forcing the user to enter a
comment. This all works fine except for one small annoying thing that is
annoying me...

When there is already a comment in the comment box & the user clicks "other",
focus is placed on the comments box but it highlights all the text. I want
it to go to the end of the line if the comments box is not null...how do I
accomplish this...still learning VBA and am stumped as to how to go about
this.

Thanks!
 
Pamela said:
I am developing a form with page breaks & subforms and am trying to do the
following:

In a subform, I have a comments box. When the user checks the "Other" check
box, I have the comments field highlighted & move the focus to the comments
box. When the user clears the "Other" check box, the comments box turns
white. If the user tried to exit the comments box without entering a
comment (when "Other" is checked), an alert pops up telling them to enter a
comment, & the focus returns to the comments box, forcing the user to enter a
comment. This all works fine except for one small annoying thing that is
annoying me...

When there is already a comment in the comment box & the user clicks "other",
focus is placed on the comments box but it highlights all the text. I want
it to go to the end of the line if the comments box is not null...how do I
accomplish this...still learning VBA and am stumped as to how to go about
this.


Typically, you would use the text box's Enter or GotFocus
event to do that.

Me.thetextbox.SelStart = Len(Nz(Me.thetextbox, "")

Note that the is a common phenemon among users that are
required data that doesn't exist or they don't know - they
just enter any old junk.
 
Thanks! I tried it & it worked perfectly. Learned a new function too (Nz).
:)

I had thought of that (entering junk), so the user ID will be recorded..
something which I now know how to do. Since this is for quality
review/tracking purposes, I'm hoping they will consider it in their best
interest to enter something meaningful. I was concerned with a previous
entry accidentally being deleted upon entry into the box, if the comments
were to be edited at a later date.

Marshall said:
I am developing a form with page breaks & subforms and am trying to do the
following:
[quoted text clipped - 13 lines]
accomplish this...still learning VBA and am stumped as to how to go about
this.

Typically, you would use the text box's Enter or GotFocus
event to do that.

Me.thetextbox.SelStart = Len(Nz(Me.thetextbox, "")

Note that the is a common phenemon among users that are
required data that doesn't exist or they don't know - they
just enter any old junk.
 
Back
Top