Continue In another textbox

C

ChoonBoy

I there a way to continue a long sentence from txtbox1 to txtbox2 and txtbox3
instead of having it wrapped in the same txtbox1.

Eg: The fox jumped over the lazy black dog

Txtbox1: The fox jumped
Txtbox2: over the lazy
Txtbox3: black dog (balance of sentance)

Reason: If I set the can grow to true, it will push all other controls when
it grows.

Thanks in advance.
 
L

Lord Kelvan

you would need an on change event on each text box

Private Sub textbox1_Change()
If Len(textbox1.Text) = 10 Then
Textbox2.SetFocus
End If
End Sub


Private Sub Textbox2_Change()
If Len(Textbox2.Text) = 10 Then
Textbox3.SetFocus
End If
End Sub

that will work of a number of characters

if you want it based on words then it is a bit more complicated

Private Sub text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 32 And InStr(text1.Text, " ") <> 0 And
InStr(Mid(text1.Text, InStr(text1.Text, " ") + 1), " ") <> 0 Then
Text2.SetFocus
End If
End Sub

Private Sub text2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 32 And InStr(Text2.Text, " ") <> 0 And
InStr(Mid(Text2.Text, InStr(Text2.Text, " ") + 1), " ") <> 0 Then
text3.SetFocus
End If
End Sub

that one will switchthe text boxes when the thirs space is entered and
will allow entering on the next box.

hope this helps

Regards
Kelvan
 
C

ChoonBoy

Thanks,

Both your codes worked. How do I make this work in Dlookup field?

Where text1 is the result of Dlookup (with long sentence which will wrap to
text2 and text3).

Regards
 
D

Dale Fye

Why not just create this as a memo field in your data table, then set the
textbox to a reasonable size and allow the text to wrap around as the user
enters it?

--
HTH
Dale

Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.
 
M

Marshall Barton

ChoonBoy said:
I there a way to continue a long sentence from txtbox1 to txtbox2 and txtbox3
instead of having it wrapped in the same txtbox1.

Eg: The fox jumped over the lazy black dog

Txtbox1: The fox jumped
Txtbox2: over the lazy
Txtbox3: black dog (balance of sentance)

Reason: If I set the can grow to true, it will push all other controls when
it grows.


Form text boxes do not grow unless you print the form, which
is almost always a bad idea.

It seems like it would be a whole lot easier to just make
the text box 3 lines tall instead of fooling around with 3
text boxes.
 
C

ChoonBoy

Thanks, but a bit more complicated for me.

I am doing this for an import form (see below)

Code ____ Goods Description ______________________ Dlookup code here!

________________________________________________

________________________________________________

If I use a textbox 3 lines tall, there will be unwanted spaces at the
beginning of row 2 and 3. I am hoping that 3 text boxes will overcome this
but do not know the best way to do it.

Thanks
 
M

Marshall Barton

What "unwanted spaces" are you talking about?

How are you getting the data into the text box that you
don't want to grow?

How should the 3 lines look on the form?
 
D

Dale Fye

There is no easy way to determine how many characters will display in a
textbox, so parsing the value that should go in those fields will be a
problem, unless you use a non-proportional font (like Courier). If you
absolutely must display the information in this format, then I would
probably have another bound textbox on my form that is bound to the
Description field. In the forms Current event, I would parse that field
something like:

me.txtDesc1 = Left(me.txtDesc, 20)
me.txtDesc2 = Mid(me.txtDesc, 21, 40)
me.txtDesc3 = Mid(me.txtDesc,61)

The problem with breaking this textbox up is that if a user wants to edit
the text in txtDesc1, you have to have code in the Change event that will
monitor how many characters are in that textbox. Then, if the user adds or
deletes characters, you either have to roll characters over into the
beginning of txtDesc2 or extract them from txtDesc2 and add them to the end
of txtDesc1. You then have to also monitor txtDesc2, and do the same with
txtDesc3.

It will be far easier to modify the form to display the code and description
label on one line, and a single, multi-line textbox below it. Something
like:

Goods Description Code ______
_________________________________
_________________________________
_________________________________
 
J

Jason

I see no sense in this. From what I see below you should have a field for
code and a seperate field for Description. To get the first so many
characters of the description field to display correctly on the first line
is quite tricky. You would need to determine how many characters are
displayed then find the last space before that and then force that onto the
next line. Same goes for the 2nd and 3rd line. Although the 2nd and 3rd line
can just be one text box 2 lines on the form and can grow/shrink on the
report. If you just use a text box that can grow and shrink on the report
and is 3 lines tall on the form it would be much tidier and easier.
 

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