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