Database n Textbox

J

John

Hello

I wonder if some one could please help me with a problem I have regarding a
database.
I am trying to write an appointment program for a friend and I need a little
assistance.

Basically the main form has the Time, date notes etc.. but I want to be able
to click a button, open another form and choose a customer to appoint to the
appointment. after clicking ok button I need the address data to be
populated in a textbox in the first form and close the customer form.
This is how i am doing it.
Firstform.txtFields(5).Text = secondform.txtFields(1).Text + vbCrLf _
'& first form.txtfields(5).Text =secondform. txtfields(2).Text

So each field for the customer address is put on a different line in the
text box.
When I try to do this i get a false statement in the text box and some pikes
i beleive they are called > ||||

Can you please help.

Thanks

John
 
J

Jezebel

At design time you have to set the textbox's Multiline property to TRUE.
Otherwise the CR and LF characters become pipes, as you observe.

The assignment statement should look something like this:

Firstform.txtFields(5).Text = secondform.txtFields(1).Text & _
vbCrLf & _
secondform.txtFields(2).Text
 
K

Ken Halter

As Jezebel mentioned... Make sure the Textbox is set to MultiLine.

On a side note, you should use & to concatenate strings and not +
Firstform.txtFields(5).Text = secondform.txtFields(1).Text + vbCrLf

Also note that if you want to add text to the end of whatever's already there, it's much
more efficient to use the SelStart/SelText properties instead of resetting the entire
text field each time... iow, instead of...

Text1.Text = Text1.Text & MoreText

use

With Text1
.SelStart = Len(.Text) 'move the cursor to the end
.SelText = MoreText 'add the text
End With

That way VB doesn't need to buffer the contents of the box before adding more.
 

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