building an array for a listbox

I

iris

Hi Everybody.

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
 
D

Doug Robbins - Word MVP

Iris,

That makes four places in this newsgroup where you have posted the same
question. Once is enough.

--
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

Sorry Doug,

I thought these are different newsgroups... :-(

I am going crasy with this....

Doug Robbins - Word MVP said:
Iris,

That makes four places in this newsgroup where you have posted the same
question. Once is enough.

--
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

iris said:
Hi Everybody.

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