Long MsgBox -- need to display in 2 paragraphs

C

C''''est_moi

I have a long MsgBox to user upon opening (autoopen) of a document that goes
like this:

MsgBox "Aaaaaaaaaaa. Bbbbbbbbbbbbb", vbInformation, "MESSAGE FROM xxx"

I want to add a line between "Aaa" and "Bbb" so when pop-up is displayed on
screen, text is divided into 2 parts, "Aaa" on one line (first paragraph
within the box) -- space -- "Bbb" on the second line (second paragraph within
the box).

I looked it up and came up with a "char(13)" carriage return function which
for the life of me, I cannot find where to insert between the "" of the
prompt after the MsgBox or how. I have tried every which way, to no avail.

Can anoyone help me?
 
G

Greg Maxey

Hopefully line breaks on your end won't wreck this:

Sub ScratchMacro()
MsgBox "Aaaaaaaaaaa." _
& vbCr & vbCr _
& "Bbbbbbbbbbbbb", _
vbInformation, "MESSAGE FROM xxx"
End Sub
 
G

Graham Mayor

To use Chr(13) in Greg's macro use it in place of vbCr eg

MsgBox "Aaaaaaaaaaa." _
& Chr(13) & Chr(13) _
& "Bbbbbbbbbbbbb", _
vbInformation, "MESSAGE FROM xxx"

The result is the same.
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
C

C''''est_moi

Greg/Graham:
Thx to the both of you. This is EXACTLY what I was hoping for. I was missing
the "&" obviously. I am getting ever more proficient in VBA thanks to you.
 
I

iris

Hi Greg

I'm trying to send you messages and failing everytime...

I will post my question here and hope you will recieve it...


I was refered to your site to see your solution to populating auserform
combobox in WORD from an access table, I used a code simillar to yours
(populating a listbox) - insted of listbox I populated a combobox - but there
is a problem there I can't solve...

It works OK with

ComboBox1.Column(0, i) = rsi.Fields("hebMakor")
to
ComboBox1.Column(9, i) = rsi.Fields("chiled")

but when it gets to

ComboBox1.Column(10, i) = rsi.Fields("mm")

it encounters error 380

"could not get the column property. Invalid property array index"

and for the lyfe of me!!!! I can't understand this!

Is there a limit on the columns number?

I tried to send you the question via your site and got an answer that

Delivery to the following recipients failed.

(e-mail address removed)

Can you Pleeeeaas!!!! I'm desperate!
 
G

Greg Maxey

Iris,

Yes. There is a 10 column limit when using an unbounded source. Consider
the following code run with two comboboxes each set with a column count =
12:

Private Sub UserForm_Initialize()
Dim myArray(11, 11) As String
Dim i As Long
Dim j As Long
With Me.ComboBox1
.AddItem
For i = 0 To 12
On Error GoTo Err_Handler
.Column(i, 0) = "Column" & i & " Test"
Next i
End With
Err_ReEntry:
For j = 0 To 11
For i = 0 To 11
myArray(j, i) = "Row" & i + 1 & " Column" & j + 1
Next i
Next j
Me.ComboBox2.Column = myArray
Exit Sub
Err_Handler:
MsgBox Err.Description
Resume Err_ReEntry
End Sub

ComboBox1 throws the error. ComboBox2 is populated with 12 rows and 12
columns.
 
I

iris

Thank you for you answer Greg!

I knew I'm not "CRAZY"!!!!

I will try your code.

Thank You very much!
 
I

iris

Hi Greg,
I have another problem in this userform... I will be very grateful if you
can help me with it...

I need to do a search of a string inside the value of a database...

for example -

I have a :

userform1 with textbox1 and a search button.

the userform is fed from a database - db1, table1, City (column)

in the textbox I want to search for the City name, not only for the first
letter - but according to any string I want... for example: if the name of
the City is New-york, I want to search for the string "yo" or for the string
"rk"...

can you show me how it's is done?

Thank You So very much!

Iris
 
I

iris

Hi Greg,

I have created a userform with a textbox1.

I want to populate this listbox with 13 columns, and give each column a title.

for example:
the listbox feeds from a database: world.db
the table is called: countryCity
and the City column in the database is called "Cities"

I columncount(0, i) = New york

I want the title of the countryCity column to be : "Tail of a City".

so the listbox should look like this:

Tail of a city country (This should be the
title)
New York New York (This is the data from
the database)

I hope I made my problem clear.... and I really REALLY hope you can help me...

Regards,

Iris
 
D

Doug Robbins - Word MVP

Listbox Column Headings (Titles) cannot be populated using VBA.

If the source of the data is an Excel Spreadsheet, and the RowSource
property of the List Box starts one row below the row that contains the
titles, then the information from the row containing the tiles will appear
as the column headings.

See: http:/support.microsoft.com/kb/q165494/

AFAIK that is the only way to populate column headings.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
D

Doug Robbins - Word MVP

No, AFAIK.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
I

iris

OK. Thank U.

I have another problem... hope U can help me with tht:

In a Word Userform I have textbox1.

I need to populate this textbox with the currrent date when I open the
userform... so the user will not have to choose the current date from a
calsendar...

do you have an idea hoe to do that?

Thank You for everything

Iris
 
I

iris

Hi Greg

I have another problem... hope you can help me...

In a Word Userform I have textbox1.

I need to populate this textbox with the currrent date when I open the
userform... so the user will not have to choose the current date from a
calsendar... the format of the date shoud be: dd/mm/yyyy

do you have an idea how to do that?

Thank You for everything

Iris
 
G

Gordon Bentley-Mix

Try

Private Sub UserForm1_Initalize()
TextBox1.Value = Format(Now, "dd/mm/yyyy")
End Sub

Although please be aware that the specified format will produce results for
the first 9 days of the month that look like "02/09/2009". You may wish to
consider using "d/mm/yyyy" instead to avoid confusion.
--
Cheers!

Gordon Bentley-Mix
Word MVP

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
 
G

Gordon Bentley-Mix

Answered in the other thread in which you posted the same question for Greg
Maxey.
--
Cheers!

Gordon Bentley-Mix
Word MVP

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
 
I

iris

Hi Greg.

I have a problem with building an array for a listbox. I hope you can help
me....

I have a userform in word that feeds from an access database.

here is the code:

Private Sub CommandButton50_Click()
Dim dbDatabase As Database
Dim rse As Recordset
Dim e As Integer
Dim i As Integer
Dim d As Boolean

Set dbDatabase = OpenDatabase("C:\nihul.mdb")
Set rse = dbDatabase.OpenRecordset("SELECT * FROM expressions ;",
dbOpenSnapshot)
Dim eStr As String
Dim answer As String
d = False
i = 0
e = 0

If TextBox1.Text = "" Then
MsgBox "Enter a search value", vbOKOnly + vbExclamation
d = True
Else

If OptionButton1.Value = False Then

MsgBox "Choose a search field", vbOKOnly + vbExclamation
d = True

Else
If OptionButton1.Value = True Then

***** MY PROBLEM STARTS HERE.... HOW DO i BUILD THE ARRAY TO POPULATE THE
LISTBOX? *****

ListBox1.Clear

With rse
Do Until .EOF
eStr = ![heb]
If InStr(![heb], TextBox1.Text) > 0 Then
d = True
i = i + 1
ListBox1.AddItem (i)
ListBox1.ColumnCount = 7
ListBox1.BoundColumn = 7
ListBox1.ColumnWidths = "4 in;1 in;1 in;1 in;1 in;1 in;0 in;"
ListBox1.Column(6, i) = ![hebrt]
ListBox1.Column(5, i) = ![heb]
ListBox1.Column(4, i) = ![engRT]
ListBox1.Column(3, i) = ![eng]
ListBox1.Column(2, i) = ![employeeName]
ListBox1.Column(1, i) = ![lastUpdate]
ListBox1.Column(0, i) = ![hebshort]

End If
.MoveNext
e = e + 1
Loop
End With
End If
End If
End If

If d = False Then
MsgBox "no values were found", vbOKOnly + vbExclamation
End If

rse.Close
dbDatabase.Close
End Sub
 

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