Memo field positioning

J

Jerry Natkin

I have a memo field in one table that can often run to several hundred
words. When reading it on a form I often have to switch to another field to
enter a note or change a value. Every time this happens the memo
repositions itself to the beginning, so that I have to scan through it,
usually scrolling down & wasting time.

Does anyone know of a way to automatically return to the earlier cursor
position inside a memo field when it is re-entered?

Thanks,

Jerry Natkin
 
A

Andy Hull

Hi Jerry

Go into the design view of your form and select the memo field.

Go to its properties and choose the Other tab.

Find the Item named Tag and enter a number 0

Now select the Event tab - click in the line named On Enter and from the
drop down box choose Event Procedure
Then click on the 3 dots to the right of this.

You will see the first and last lines of the following code.
Add the other 2 lines remembering to replace memo_field with the name of
your memo field.

Private Sub memo_text_Enter()

Me.memo_field.SelStart = Len(Me.memo_field)
Me.memo_field.SelStart = Me.memo_field.Tag

End Sub

You can then close the vba code window which will take you back to the memo
fields properties.
Click in the line named On Exit and again from the drop down box choose
Event Procedure and click on the 3 dots to the right of this.

As before, the first & last lines (below) will be created for you so add in
the middle line.

Private Sub memo_field_Exit(Cancel As Integer)

Me.memo_field.Tag = Me.memo_field.SelStart

End Sub

Close the vba code window, and the properties sheets and close and save the
form.

Now, when you click away from the memo field it still resets to the
beginning but when you tab or click back it resets to where the cursor last
was.

hth

Andy Hull
 
J

Jerry Natkin

Thanks Andy; it worked fine.

Jerry


Hi Jerry

Go into the design view of your form and select the memo field.

Go to its properties and choose the Other tab.

Find the Item named Tag and enter a number 0

Now select the Event tab - click in the line named On Enter and from
the drop down box choose Event Procedure
Then click on the 3 dots to the right of this.

You will see the first and last lines of the following code.
Add the other 2 lines remembering to replace memo_field with the name
of your memo field.

Private Sub memo_text_Enter()

Me.memo_field.SelStart = Len(Me.memo_field)
Me.memo_field.SelStart = Me.memo_field.Tag

End Sub

You can then close the vba code window which will take you back to the
memo fields properties.
Click in the line named On Exit and again from the drop down box
choose Event Procedure and click on the 3 dots to the right of this.

As before, the first & last lines (below) will be created for you so
add in the middle line.

Private Sub memo_field_Exit(Cancel As Integer)

Me.memo_field.Tag = Me.memo_field.SelStart

End Sub

Close the vba code window, and the properties sheets and close and
save the form.

Now, when you click away from the memo field it still resets to the
beginning but when you tab or click back it resets to where the cursor
last was.

hth

Andy Hull
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top