Memo-field

J

Jean-Paul

Hi,

I have a table with 2 fields...
and ID field and a memofield.

When I open the form based upon this table, I would like to, immediatly
jump to the last word of the memofield..
Is that possible?

Also, how to add a "return" to lines that are added during working with
the rest of the program?

Thanks
 
T

tina

to jump to the end of the text, in the form, you can add code to the
control's Enter event, as

Me!ControlName.SelStart = Me!ControlName.SelLength + 1
Also, how to add a "return" to lines that are added during working with
the rest of the program?

not sure what you mean here. when and how are these lines added? from other
data entry? by using an Update query? by VBA code?

hth
 
J

Jean-Paul

thank you Tina for your kind reply..
But,

I can't find the Enter event... (I have a DUtch version)
Maybe you can tell me next to what properties it can be found

As to the "return"
During working with the program users can (as an example) make a diary
to visit companies
I created a memo-field linked to the company data
In this memofield I want to add something like "Company ABC is visited..."
Everything the user does concerning the company will be added to the
memofield so finally when you check the companie's memofield you will
have an idea of what has been pointed out...

hope you understand now....
 
T

tina

I can't find the Enter event... (I have a DUtch version)
Maybe you can tell me next to what properties it can be found

well, i'll give you the directions i'd give to someone using the American
(?) version, hopefully your version is similar enough that it will help.

open the form in Design view. click once on the control bound to the memo
field, to select it. open the Properties box and click on the Event tab,
scroll down if necessary until you see the "On Enter" event in the list.
I created a memo-field linked to the company data
In this memofield I want to add something like "Company ABC is visited..."

okay, but the question remains: *how* are you adding the text? manually, by
typing it in? with a Update query? by VBA code? some other way? and when:
at the point when the user does whatever-it-is? or at some later point?

hth
 
J

Jean-Paul

OK... found, it's the 6th item of the list...

as to the second part...
I have (among other) a form with a "save" pushbutton....
Data are saved but also record is added in the memo-table with following
code:

sql = "SELECT Remarks.* FROM Remarks WHERE Remarks.Bedrijf_ID=" &
Forms!Bedrijven!bedrijfsnummer & ";"
Set Tb = db.OpenRecordset(sql)
If Tb.RecordCount = 0 Then
Tb.AddNew
Tb!Bedrijf_ID = Forms!Bedrijven!bedrijfsnummer
Tb!Opmerking = "Bedrijf werd bezocht op " & Me!Dat_bezoek
Tb.Update
Else
............

The table is Remarks
The memofield is "Opmerking"

When I look at the memo-table I would like to get all details I added to
appear on a new line... so I think, I need to add a CTRL somewhere...
Did I make it clear now?...

Thanks for your patience
JP
 
J

Jean-Paul

also..
what happens with he code you send:

Private Sub Opmerking_Enter()
Me!Opmerking.SelStart = Me!Opmerking.SelLength + 1
End Sub

When the form is opened, with the memofield, you only see the last
line..... the memofields scrolls down maximally so the lines above the
last line are "scrolled" away.
The other lines are there but you have to maunally scroll upwards...

JP
 
T

tina

well, yes, that's what will happen if you place the cursor at the end of the
existing text. if you want the user to see the text at the "top" of the
control when the form is opened, you could add a tabstop control to take the
focus first, rather than the memo control. then the user can start reading
from the top. however, as soon as the user clicks on a scroll bar in the
control to scroll down or to the side, the Enter event code will fire,
jumping the cursor to the end of the text.

as an alternative fix to the Enter event, you might try moving the code to
another event, perhaps the control's MouseUp event. then revise the code to
run only when the right mouse button is clicked, as

If Button = acRightButton Then Me!Opmerking.SelStart =
Me!Opmerking.SelLength + 1

the above code goes all on one line, regardless of line-wrap in this post.

hth
 
T

tina

well, since you're adding a new memo record, not adding text to existing
data in an existing memo record, i'm not quite sure where you want the "new
line" to start, but here's my guess at what you're after, as

Tb!Opmerking = "Bedrijf werd bezocht op " _
& vbCR & Me!Dat_bezoek

i didn't test the above, so if it's the right idea, but doesn't work, try

Tb!Opmerking = "Bedrijf werd bezocht op " _
& Chr(13) & Chr(10) & Me!Dat_bezoek

i put in the line breaks just to prevent uncontrolled line wrap in this
post; you can use the line breaks or remove them and run the code all on one
line, your choice.

hth
 

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