Building an array within another array ...

I

iris

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

In that form I have :
textbox1 - in which i write the string I need to search
optionbutton1 - in which I choose the column I need to search the string in
the database
comandbutton1 - to execute the search
listbox1 - in which I need the list of the results to appear

The code I wrote execute the search sucssessfully but I don't know how to
build the array for all the resualts.... I only get one resault at a time and
eventually - only the last resault appears in the list box.

I need all the resualts to appear in the listbox.

can someone please help me write the code correctly...?

This is the code I wrote:

Private Sub CommandButton1_Click()

Dim dbDatabase As Database
Dim rse As Recordset
Dim rsi 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 myActiveRecord As Recordset
Dim x As Long
x = 0


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 category", vbOKOnly + vbExclamation
d = True
Else
If OptionButton1.Value = True Then

ListBox1.Clear

With rse
Do Until .EOF
eStr = ![heb]
If InStr(![heb], TextBox1.Text) > 0 Then
d = True
i = i + 1
TextBox2.Text = ![heb]
ListBox1.AddItem


Set dbDatabase = OpenDatabase("C:\nihul.mdb")

Set myActiveRecord = myDataBase.OpenRecordset("SELECT * FROM expressions
WHERE heb = '" & TextBox2.Text & "'", dbOpenForwardOnly)

ListBox1.ColumnCount = myActiveRecord.Fields.Count

Do While Not myActiveRecord.EOF
ListBox1.AddItem
ListBox1.ColumnCount = 7
ListBox1.BoundColumn = 7
ListBox1.ColumnWidths = "4 in;1 in;1 in;1 in;1 in;1 in;0 in;"
ListBox1.List(x, 6) = myActiveRecord.Fields("hebrt")
ListBox1.List(x, 5) = myActiveRecord.Fields("heb")
ListBox1.List(x, 4) = myActiveRecord.Fields("engRT")
ListBox1.List(x, 3) = myActiveRecord.Fields("eng")
ListBox1.List(x, 2) = myActiveRecord.Fields("employeeName")
ListBox1.List(x, 1) = myActiveRecord.Fields("lastUpdate")
ListBox1.List(x, 0) = myActiveRecord.Fields("hebshort")
x = x + x

myActiveRecord.MoveNext
Loop

myActiveRecord.Close
myDataBase.Close
Set myActiveRecord = Nothing
Set myDataBase = Nothing

answer = MsgBox("R U sure?" & TextBox1.Text & ". ,
vbQuestion)
If answer = vbNo Then
Exit Sub
Else
End If
End If
.MoveNext
e = e + 1
Loop
End With
End If
End If
End If

rse.Close
dbDatabase.Close
If d = False Then
MsgBox "no resaults are found", vbOKOnly + vbExclamation
End If

End Sub
 
D

Doug Robbins - Word MVP

I would suggest that instead of having a textbox into which the user enters
something to search for which may not be present in the object being
searched, you should populate a combobox on the userform with the items from
which the user can select the one that they want to then be used as the
basis for filtering the data that you then want to load into a listbox.

I would also suggest that you start to give meaningful names to the controls
on your form rather than using names such as TextBox1, OptButton1 or
ListBox1.

Here is some code in which the Userform_Initialize event populates a
combobox (cmbPayee) with data from a table in an Access database in which
the Payee is the first field and then the cmbPayee_Change event populates a
listbox (lstPayments) with the records from the table where the Payee
matches the item selected in the cmbPayee

Private Sub UserForm_Initialize()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim NoOfRecords As Long
' Open the database
Set db = OpenDatabase("C:\Documents and Settings\Doug Robbins\My
Documents\Cost Database\Cost Control System Back End.mdb")
' Retrieve the recordset
Set rs = db.OpenRecordset("SELECT * FROM [tblRecorded Costs] ORDER BY
Payee")
' Determine the number of retrieved records
With rs
.MoveLast
NoOfRecords = .RecordCount
.MoveFirst
End With
' Set the number of Columns = number of Fields in recordset
cmbPayee.ColumnCount = rs.Fields.Count
' Load the ListBox with the retrieved records
cmbPayee.Column = rs.GetRows(NoOfRecords)
' Cleanup
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
End Sub

Private Sub cmbPayee_Change()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim NoOfRecords As Long
' Open the database
Set db = OpenDatabase("C:\Documents and Settings\Doug Robbins\My
Documents\Cost Database\Cost Control System Back End.mdb")
' Retrieve the recordset
Set rs = db.OpenRecordset("SELECT * FROM [tblRecorded Costs]
WHERE([tblRecorded Costs].Payee = " & Chr(34) & cmbPayee.Value & Chr(34) &
")")
' Determine the number of retrieved records
With rs
.MoveLast
NoOfRecords = .RecordCount
.MoveFirst
End With
' Set the number of Columns = number of Fields in recordset
lstPayments.ColumnCount = rs.Fields.Count
' Load the ListBox with the retrieved records
lstPayments.Column = rs.GetRows(NoOfRecords)
' Cleanup
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
End Sub

Please do not post the same question mutliple times to the newsgroups.
--
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:
I have a userform1 in word that feeds from an access database.

In that form I have :
textbox1 - in which i write the string I need to search
optionbutton1 - in which I choose the column I need to search the string
in
the database
comandbutton1 - to execute the search
listbox1 - in which I need the list of the results to appear

The code I wrote execute the search sucssessfully but I don't know how to
build the array for all the resualts.... I only get one resault at a time
and
eventually - only the last resault appears in the list box.

I need all the resualts to appear in the listbox.

can someone please help me write the code correctly...?

This is the code I wrote:

Private Sub CommandButton1_Click()

Dim dbDatabase As Database
Dim rse As Recordset
Dim rsi 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 myActiveRecord As Recordset
Dim x As Long
x = 0


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 category", vbOKOnly + vbExclamation
d = True
Else
If OptionButton1.Value = True Then

ListBox1.Clear

With rse
Do Until .EOF
eStr = ![heb]
If InStr(![heb], TextBox1.Text) > 0 Then
d = True
i = i + 1
TextBox2.Text = ![heb]
ListBox1.AddItem


Set dbDatabase = OpenDatabase("C:\nihul.mdb")

Set myActiveRecord = myDataBase.OpenRecordset("SELECT * FROM expressions
WHERE heb = '" & TextBox2.Text & "'", dbOpenForwardOnly)

ListBox1.ColumnCount = myActiveRecord.Fields.Count

Do While Not myActiveRecord.EOF
ListBox1.AddItem
ListBox1.ColumnCount = 7
ListBox1.BoundColumn = 7
ListBox1.ColumnWidths = "4 in;1 in;1 in;1 in;1 in;1 in;0 in;"
ListBox1.List(x, 6) = myActiveRecord.Fields("hebrt")
ListBox1.List(x, 5) = myActiveRecord.Fields("heb")
ListBox1.List(x, 4) = myActiveRecord.Fields("engRT")
ListBox1.List(x, 3) = myActiveRecord.Fields("eng")
ListBox1.List(x, 2) = myActiveRecord.Fields("employeeName")
ListBox1.List(x, 1) = myActiveRecord.Fields("lastUpdate")
ListBox1.List(x, 0) = myActiveRecord.Fields("hebshort")
x = x + x

myActiveRecord.MoveNext
Loop

myActiveRecord.Close
myDataBase.Close
Set myActiveRecord = Nothing
Set myDataBase = Nothing

answer = MsgBox("R U sure?" & TextBox1.Text & ". ,
vbQuestion)
If answer = vbNo Then
Exit Sub
Else
End If
End If
.MoveNext
e = e + 1
Loop
End With
End If
End If
End If

rse.Close
dbDatabase.Close
If d = False Then
MsgBox "no resaults are found", vbOKOnly + vbExclamation
End If

End Sub
 
I

iris

Hi Doug,

Thank you very much for your answer! :) I appriciate this very much !!

To populate combobox will be the best and easiest thing to do. But I need to
find a word inside the sentence: for example: with a senctence like "I am
living in New York City"

In a combobox there is no problem if you search from the first word: "I
am...." and so on...

My problem is that I want to search inside the sentence: for example - the
word "living" - and I want to see all the resaults of this search - their
could be 20 or more resaults - that is why I need to populate a listbox with
the resaults...

thank you again for your answer.... I hope you will be able to help me with
that...

and sorry again for the multiple postings... my mistake...


iris said:
I have a userform1 in word that feeds from an access database.

In that form I have :
textbox1 - in which i write the string I need to search
optionbutton1 - in which I choose the column I need to search the string in
the database
comandbutton1 - to execute the search
listbox1 - in which I need the list of the results to appear

The code I wrote execute the search sucssessfully but I don't know how to
build the array for all the resualts.... I only get one resault at a time and
eventually - only the last resault appears in the list box.

I need all the resualts to appear in the listbox.

can someone please help me write the code correctly...?

This is the code I wrote:

Private Sub CommandButton1_Click()

Dim dbDatabase As Database
Dim rse As Recordset
Dim rsi 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 myActiveRecord As Recordset
Dim x As Long
x = 0


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 category", vbOKOnly + vbExclamation
d = True
Else
If OptionButton1.Value = True Then

ListBox1.Clear

With rse
Do Until .EOF
eStr = ![heb]
If InStr(![heb], TextBox1.Text) > 0 Then
d = True
i = i + 1
TextBox2.Text = ![heb]
ListBox1.AddItem


Set dbDatabase = OpenDatabase("C:\nihul.mdb")

Set myActiveRecord = myDataBase.OpenRecordset("SELECT * FROM expressions
WHERE heb = '" & TextBox2.Text & "'", dbOpenForwardOnly)

ListBox1.ColumnCount = myActiveRecord.Fields.Count

Do While Not myActiveRecord.EOF
ListBox1.AddItem
ListBox1.ColumnCount = 7
ListBox1.BoundColumn = 7
ListBox1.ColumnWidths = "4 in;1 in;1 in;1 in;1 in;1 in;0 in;"
ListBox1.List(x, 6) = myActiveRecord.Fields("hebrt")
ListBox1.List(x, 5) = myActiveRecord.Fields("heb")
ListBox1.List(x, 4) = myActiveRecord.Fields("engRT")
ListBox1.List(x, 3) = myActiveRecord.Fields("eng")
ListBox1.List(x, 2) = myActiveRecord.Fields("employeeName")
ListBox1.List(x, 1) = myActiveRecord.Fields("lastUpdate")
ListBox1.List(x, 0) = myActiveRecord.Fields("hebshort")
x = x + x

myActiveRecord.MoveNext
Loop

myActiveRecord.Close
myDataBase.Close
Set myActiveRecord = Nothing
Set myDataBase = Nothing

answer = MsgBox("R U sure?" & TextBox1.Text & ". ,
vbQuestion)
If answer = vbNo Then
Exit Sub
Else
End If
End If
.MoveNext
e = e + 1
Loop
End With
End If
End If
End If

rse.Close
dbDatabase.Close
If d = False Then
MsgBox "no resaults are found", vbOKOnly + vbExclamation
End If

End Sub
 
D

Doug Robbins - Word MVP

In that case, you would use a command button (cmdShowPayments) with the
following code that would load the listbox with the payments made to a payee
whose name was entered into a textbox control txtPayee

Private Sub cmdShowPayments_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim NoOfRecords As Long
' Open the database
Set db = OpenDatabase("C:\Documents and Settings\Doug Robbins\My
Documents\Cost Database\Cost Control System Back End.mdb")
' Retrieve the recordset
Set rs = db.OpenRecordset("SELECT * FROM [tblRecorded Costs]
WHERE([tblRecorded Costs].Payee = " & Chr(34) & txtPayee.Text & Chr(34) &
")")
' Determine the number of retrieved records
With rs
.MoveLast
NoOfRecords = .RecordCount
.MoveFirst
End With
' Set the number of Columns = number of Fields in recordset
lstPayments.ColumnCount = rs.Fields.Count
' Load the ListBox with the retrieved records
lstPayments.Column = rs.GetRows(NoOfRecords)
' Cleanup
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
End Sub


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

Thank you very much for your answer! :) I appriciate this very much !!

To populate combobox will be the best and easiest thing to do. But I need
to
find a word inside the sentence: for example: with a senctence like "I am
living in New York City"

In a combobox there is no problem if you search from the first word: "I
am...." and so on...

My problem is that I want to search inside the sentence: for example - the
word "living" - and I want to see all the resaults of this search - their
could be 20 or more resaults - that is why I need to populate a listbox
with
the resaults...

thank you again for your answer.... I hope you will be able to help me
with
that...

and sorry again for the multiple postings... my mistake...


iris said:
I have a userform1 in word that feeds from an access database.

In that form I have :
textbox1 - in which i write the string I need to search
optionbutton1 - in which I choose the column I need to search the string
in
the database
comandbutton1 - to execute the search
listbox1 - in which I need the list of the results to appear

The code I wrote execute the search sucssessfully but I don't know how
to
build the array for all the resualts.... I only get one resault at a time
and
eventually - only the last resault appears in the list box.

I need all the resualts to appear in the listbox.

can someone please help me write the code correctly...?

This is the code I wrote:

Private Sub CommandButton1_Click()

Dim dbDatabase As Database
Dim rse As Recordset
Dim rsi 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 myActiveRecord As Recordset
Dim x As Long
x = 0


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 category", vbOKOnly + vbExclamation
d = True
Else
If OptionButton1.Value = True Then

ListBox1.Clear

With rse
Do Until .EOF
eStr = ![heb]
If InStr(![heb], TextBox1.Text) > 0 Then
d = True
i = i + 1
TextBox2.Text = ![heb]
ListBox1.AddItem


Set dbDatabase = OpenDatabase("C:\nihul.mdb")

Set myActiveRecord = myDataBase.OpenRecordset("SELECT * FROM expressions
WHERE heb = '" & TextBox2.Text & "'", dbOpenForwardOnly)

ListBox1.ColumnCount = myActiveRecord.Fields.Count

Do While Not myActiveRecord.EOF
ListBox1.AddItem
ListBox1.ColumnCount = 7
ListBox1.BoundColumn = 7
ListBox1.ColumnWidths = "4 in;1 in;1 in;1 in;1 in;1 in;0 in;"
ListBox1.List(x, 6) = myActiveRecord.Fields("hebrt")
ListBox1.List(x, 5) = myActiveRecord.Fields("heb")
ListBox1.List(x, 4) = myActiveRecord.Fields("engRT")
ListBox1.List(x, 3) = myActiveRecord.Fields("eng")
ListBox1.List(x, 2) = myActiveRecord.Fields("employeeName")
ListBox1.List(x, 1) = myActiveRecord.Fields("lastUpdate")
ListBox1.List(x, 0) = myActiveRecord.Fields("hebshort")
x = x + x

myActiveRecord.MoveNext
Loop

myActiveRecord.Close
myDataBase.Close
Set myActiveRecord = Nothing
Set myDataBase = Nothing

answer = MsgBox("R U sure?" & TextBox1.Text & ". ,
vbQuestion)
If answer = vbNo Then
Exit Sub
Else
End If
End If
.MoveNext
e = e + 1
Loop
End With
End If
End If
End If

rse.Close
dbDatabase.Close
If d = False Then
MsgBox "no resaults are found", vbOKOnly + vbExclamation
End If

End Sub
 
I

iris

Thank you so much Doug!

I will try it and fill you up tomorrow.
It is now 2:30 (17/2) am and I am working on this since 06:00 (16/2)...

I hardli open my eyes....

Good night and trully trully thank you for your wilingness to help!!!

Talk to you tomorrow... :)


iris said:
Hi Doug,

Thank you very much for your answer! :) I appriciate this very much !!

To populate combobox will be the best and easiest thing to do. But I need to
find a word inside the sentence: for example: with a senctence like "I am
living in New York City"

In a combobox there is no problem if you search from the first word: "I
am...." and so on...

My problem is that I want to search inside the sentence: for example - the
word "living" - and I want to see all the resaults of this search - their
could be 20 or more resaults - that is why I need to populate a listbox with
the resaults...

thank you again for your answer.... I hope you will be able to help me with
that...

and sorry again for the multiple postings... my mistake...


iris said:
I have a userform1 in word that feeds from an access database.

In that form I have :
textbox1 - in which i write the string I need to search
optionbutton1 - in which I choose the column I need to search the string in
the database
comandbutton1 - to execute the search
listbox1 - in which I need the list of the results to appear

The code I wrote execute the search sucssessfully but I don't know how to
build the array for all the resualts.... I only get one resault at a time and
eventually - only the last resault appears in the list box.

I need all the resualts to appear in the listbox.

can someone please help me write the code correctly...?

This is the code I wrote:

Private Sub CommandButton1_Click()

Dim dbDatabase As Database
Dim rse As Recordset
Dim rsi 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 myActiveRecord As Recordset
Dim x As Long
x = 0


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 category", vbOKOnly + vbExclamation
d = True
Else
If OptionButton1.Value = True Then

ListBox1.Clear

With rse
Do Until .EOF
eStr = ![heb]
If InStr(![heb], TextBox1.Text) > 0 Then
d = True
i = i + 1
TextBox2.Text = ![heb]
ListBox1.AddItem


Set dbDatabase = OpenDatabase("C:\nihul.mdb")

Set myActiveRecord = myDataBase.OpenRecordset("SELECT * FROM expressions
WHERE heb = '" & TextBox2.Text & "'", dbOpenForwardOnly)

ListBox1.ColumnCount = myActiveRecord.Fields.Count

Do While Not myActiveRecord.EOF
ListBox1.AddItem
ListBox1.ColumnCount = 7
ListBox1.BoundColumn = 7
ListBox1.ColumnWidths = "4 in;1 in;1 in;1 in;1 in;1 in;0 in;"
ListBox1.List(x, 6) = myActiveRecord.Fields("hebrt")
ListBox1.List(x, 5) = myActiveRecord.Fields("heb")
ListBox1.List(x, 4) = myActiveRecord.Fields("engRT")
ListBox1.List(x, 3) = myActiveRecord.Fields("eng")
ListBox1.List(x, 2) = myActiveRecord.Fields("employeeName")
ListBox1.List(x, 1) = myActiveRecord.Fields("lastUpdate")
ListBox1.List(x, 0) = myActiveRecord.Fields("hebshort")
x = x + x

myActiveRecord.MoveNext
Loop

myActiveRecord.Close
myDataBase.Close
Set myActiveRecord = Nothing
Set myDataBase = Nothing

answer = MsgBox("R U sure?" & TextBox1.Text & ". ,
vbQuestion)
If answer = vbNo Then
Exit Sub
Else
End If
End If
.MoveNext
e = e + 1
Loop
End With
End If
End If
End If

rse.Close
dbDatabase.Close
If d = False Then
MsgBox "no resaults are found", vbOKOnly + vbExclamation
End If

End Sub
 
G

Gordon Bentley-Mix

Doug,

" I will ... fill you up tomorrow."

Who's a lucky boy then? ;-P
--
Cheers!

Gordon Bentley-Mix
Word MVP

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


iris said:
Thank you so much Doug!

I will try it and fill you up tomorrow.
It is now 2:30 (17/2) am and I am working on this since 06:00 (16/2)...

I hardli open my eyes....

Good night and trully trully thank you for your wilingness to help!!!

Talk to you tomorrow... :)


iris said:
Hi Doug,

Thank you very much for your answer! :) I appriciate this very much !!

To populate combobox will be the best and easiest thing to do. But I need to
find a word inside the sentence: for example: with a senctence like "I am
living in New York City"

In a combobox there is no problem if you search from the first word: "I
am...." and so on...

My problem is that I want to search inside the sentence: for example - the
word "living" - and I want to see all the resaults of this search - their
could be 20 or more resaults - that is why I need to populate a listbox with
the resaults...

thank you again for your answer.... I hope you will be able to help me with
that...

and sorry again for the multiple postings... my mistake...


iris said:
I have a userform1 in word that feeds from an access database.

In that form I have :
textbox1 - in which i write the string I need to search
optionbutton1 - in which I choose the column I need to search the string in
the database
comandbutton1 - to execute the search
listbox1 - in which I need the list of the results to appear

The code I wrote execute the search sucssessfully but I don't know how to
build the array for all the resualts.... I only get one resault at a time and
eventually - only the last resault appears in the list box.

I need all the resualts to appear in the listbox.

can someone please help me write the code correctly...?

This is the code I wrote:

Private Sub CommandButton1_Click()

Dim dbDatabase As Database
Dim rse As Recordset
Dim rsi 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 myActiveRecord As Recordset
Dim x As Long
x = 0


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 category", vbOKOnly + vbExclamation
d = True
Else
If OptionButton1.Value = True Then

ListBox1.Clear

With rse
Do Until .EOF
eStr = ![heb]
If InStr(![heb], TextBox1.Text) > 0 Then
d = True
i = i + 1
TextBox2.Text = ![heb]
ListBox1.AddItem


Set dbDatabase = OpenDatabase("C:\nihul.mdb")

Set myActiveRecord = myDataBase.OpenRecordset("SELECT * FROM expressions
WHERE heb = '" & TextBox2.Text & "'", dbOpenForwardOnly)

ListBox1.ColumnCount = myActiveRecord.Fields.Count

Do While Not myActiveRecord.EOF
ListBox1.AddItem
ListBox1.ColumnCount = 7
ListBox1.BoundColumn = 7
ListBox1.ColumnWidths = "4 in;1 in;1 in;1 in;1 in;1 in;0 in;"
ListBox1.List(x, 6) = myActiveRecord.Fields("hebrt")
ListBox1.List(x, 5) = myActiveRecord.Fields("heb")
ListBox1.List(x, 4) = myActiveRecord.Fields("engRT")
ListBox1.List(x, 3) = myActiveRecord.Fields("eng")
ListBox1.List(x, 2) = myActiveRecord.Fields("employeeName")
ListBox1.List(x, 1) = myActiveRecord.Fields("lastUpdate")
ListBox1.List(x, 0) = myActiveRecord.Fields("hebshort")
x = x + x

myActiveRecord.MoveNext
Loop

myActiveRecord.Close
myDataBase.Close
Set myActiveRecord = Nothing
Set myDataBase = Nothing

answer = MsgBox("R U sure?" & TextBox1.Text & ". ,
vbQuestion)
If answer = vbNo Then
Exit Sub
Else
End If
End If
.MoveNext
e = e + 1
Loop
End With
End If
End If
End If

rse.Close
dbDatabase.Close
If d = False Then
MsgBox "no resaults are found", vbOKOnly + vbExclamation
End If

End Sub
 
I

iris

Oooooooohhhhhh.... I gess I wrote this wrong havn't I Gordon...:)

But... If it maid you lough.... It's the least I can do....

I must work on my English.... a second after I'll finish this thing....

Cheers to you to...



Gordon Bentley-Mix said:
Doug,

" I will ... fill you up tomorrow."

Who's a lucky boy then? ;-P
--
Cheers!

Gordon Bentley-Mix
Word MVP

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


iris said:
Thank you so much Doug!

I will try it and fill you up tomorrow.
It is now 2:30 (17/2) am and I am working on this since 06:00 (16/2)...

I hardli open my eyes....

Good night and trully trully thank you for your wilingness to help!!!

Talk to you tomorrow... :)


iris said:
Hi Doug,

Thank you very much for your answer! :) I appriciate this very much !!

To populate combobox will be the best and easiest thing to do. But I need to
find a word inside the sentence: for example: with a senctence like "I am
living in New York City"

In a combobox there is no problem if you search from the first word: "I
am...." and so on...

My problem is that I want to search inside the sentence: for example - the
word "living" - and I want to see all the resaults of this search - their
could be 20 or more resaults - that is why I need to populate a listbox with
the resaults...

thank you again for your answer.... I hope you will be able to help me with
that...

and sorry again for the multiple postings... my mistake...


:

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

In that form I have :
textbox1 - in which i write the string I need to search
optionbutton1 - in which I choose the column I need to search the string in
the database
comandbutton1 - to execute the search
listbox1 - in which I need the list of the results to appear

The code I wrote execute the search sucssessfully but I don't know how to
build the array for all the resualts.... I only get one resault at a time and
eventually - only the last resault appears in the list box.

I need all the resualts to appear in the listbox.

can someone please help me write the code correctly...?

This is the code I wrote:

Private Sub CommandButton1_Click()

Dim dbDatabase As Database
Dim rse As Recordset
Dim rsi 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 myActiveRecord As Recordset
Dim x As Long
x = 0


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 category", vbOKOnly + vbExclamation
d = True
Else
If OptionButton1.Value = True Then

ListBox1.Clear

With rse
Do Until .EOF
eStr = ![heb]
If InStr(![heb], TextBox1.Text) > 0 Then
d = True
i = i + 1
TextBox2.Text = ![heb]
ListBox1.AddItem


Set dbDatabase = OpenDatabase("C:\nihul.mdb")

Set myActiveRecord = myDataBase.OpenRecordset("SELECT * FROM expressions
WHERE heb = '" & TextBox2.Text & "'", dbOpenForwardOnly)

ListBox1.ColumnCount = myActiveRecord.Fields.Count

Do While Not myActiveRecord.EOF
ListBox1.AddItem
ListBox1.ColumnCount = 7
ListBox1.BoundColumn = 7
ListBox1.ColumnWidths = "4 in;1 in;1 in;1 in;1 in;1 in;0 in;"
ListBox1.List(x, 6) = myActiveRecord.Fields("hebrt")
ListBox1.List(x, 5) = myActiveRecord.Fields("heb")
ListBox1.List(x, 4) = myActiveRecord.Fields("engRT")
ListBox1.List(x, 3) = myActiveRecord.Fields("eng")
ListBox1.List(x, 2) = myActiveRecord.Fields("employeeName")
ListBox1.List(x, 1) = myActiveRecord.Fields("lastUpdate")
ListBox1.List(x, 0) = myActiveRecord.Fields("hebshort")
x = x + x

myActiveRecord.MoveNext
Loop

myActiveRecord.Close
myDataBase.Close
Set myActiveRecord = Nothing
Set myDataBase = Nothing

answer = MsgBox("R U sure?" & TextBox1.Text & ". ,
vbQuestion)
If answer = vbNo Then
Exit Sub
Else
End If
End If
.MoveNext
e = e + 1
Loop
End With
End If
End If
End If

rse.Close
dbDatabase.Close
If d = False Then
MsgBox "no resaults are found", vbOKOnly + vbExclamation
End If

End Sub
 
I

iris

Hi Doug,

This code is great to fill a listbox without a condition... but... my
problem is that I need to have a condition... I need to find a word inside a
sentence and not all the sentence...

Greg has suggested :

Sub Whatever()
Dim pStr As String
If InStr(Me.textbox16.Text, "Yo") > 0 Or Instr(Me.textboxt16.Text, "rk") > 0
Then
pStr = "New York City"
End If

This code works great too.... I am failing miserably in combining the two
codes... that is where I'm stuck...

after checking that this condition is true - then start column count...

The second problem is:
I need to show only 2 columns - and not all the columns of the recordset in
the listbox...

I Hope you can help me with that.

Thank you,

Iris





Doug Robbins - Word MVP said:
In that case, you would use a command button (cmdShowPayments) with the
following code that would load the listbox with the payments made to a payee
whose name was entered into a textbox control txtPayee

Private Sub cmdShowPayments_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim NoOfRecords As Long
' Open the database
Set db = OpenDatabase("C:\Documents and Settings\Doug Robbins\My
Documents\Cost Database\Cost Control System Back End.mdb")
' Retrieve the recordset
Set rs = db.OpenRecordset("SELECT * FROM [tblRecorded Costs]
WHERE([tblRecorded Costs].Payee = " & Chr(34) & txtPayee.Text & Chr(34) &
")")
' Determine the number of retrieved records
With rs
.MoveLast
NoOfRecords = .RecordCount
.MoveFirst
End With
' Set the number of Columns = number of Fields in recordset
lstPayments.ColumnCount = rs.Fields.Count
' Load the ListBox with the retrieved records
lstPayments.Column = rs.GetRows(NoOfRecords)
' Cleanup
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
End Sub


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

Thank you very much for your answer! :) I appriciate this very much !!

To populate combobox will be the best and easiest thing to do. But I need
to
find a word inside the sentence: for example: with a senctence like "I am
living in New York City"

In a combobox there is no problem if you search from the first word: "I
am...." and so on...

My problem is that I want to search inside the sentence: for example - the
word "living" - and I want to see all the resaults of this search - their
could be 20 or more resaults - that is why I need to populate a listbox
with
the resaults...

thank you again for your answer.... I hope you will be able to help me
with
that...

and sorry again for the multiple postings... my mistake...


iris said:
I have a userform1 in word that feeds from an access database.

In that form I have :
textbox1 - in which i write the string I need to search
optionbutton1 - in which I choose the column I need to search the string
in
the database
comandbutton1 - to execute the search
listbox1 - in which I need the list of the results to appear

The code I wrote execute the search sucssessfully but I don't know how
to
build the array for all the resualts.... I only get one resault at a time
and
eventually - only the last resault appears in the list box.

I need all the resualts to appear in the listbox.

can someone please help me write the code correctly...?

This is the code I wrote:

Private Sub CommandButton1_Click()

Dim dbDatabase As Database
Dim rse As Recordset
Dim rsi 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 myActiveRecord As Recordset
Dim x As Long
x = 0


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 category", vbOKOnly + vbExclamation
d = True
Else
If OptionButton1.Value = True Then

ListBox1.Clear

With rse
Do Until .EOF
eStr = ![heb]
If InStr(![heb], TextBox1.Text) > 0 Then
d = True
i = i + 1
TextBox2.Text = ![heb]
ListBox1.AddItem


Set dbDatabase = OpenDatabase("C:\nihul.mdb")

Set myActiveRecord = myDataBase.OpenRecordset("SELECT * FROM expressions
WHERE heb = '" & TextBox2.Text & "'", dbOpenForwardOnly)

ListBox1.ColumnCount = myActiveRecord.Fields.Count

Do While Not myActiveRecord.EOF
ListBox1.AddItem
ListBox1.ColumnCount = 7
ListBox1.BoundColumn = 7
ListBox1.ColumnWidths = "4 in;1 in;1 in;1 in;1 in;1 in;0 in;"
ListBox1.List(x, 6) = myActiveRecord.Fields("hebrt")
ListBox1.List(x, 5) = myActiveRecord.Fields("heb")
ListBox1.List(x, 4) = myActiveRecord.Fields("engRT")
ListBox1.List(x, 3) = myActiveRecord.Fields("eng")
ListBox1.List(x, 2) = myActiveRecord.Fields("employeeName")
ListBox1.List(x, 1) = myActiveRecord.Fields("lastUpdate")
ListBox1.List(x, 0) = myActiveRecord.Fields("hebshort")
x = x + x

myActiveRecord.MoveNext
Loop

myActiveRecord.Close
myDataBase.Close
Set myActiveRecord = Nothing
Set myDataBase = Nothing

answer = MsgBox("R U sure?" & TextBox1.Text & ". ,
vbQuestion)
If answer = vbNo Then
Exit Sub
Else
End If
End If
.MoveNext
e = e + 1
Loop
End With
End If
End If
End If

rse.Close
dbDatabase.Close
If d = False Then
MsgBox "no resaults are found", vbOKOnly + vbExclamation
End If

End Sub
 
D

Doug Robbins - Word MVP

In my code, the condition is applied by the WHERE in the following:

Set rs = db.OpenRecordset("SELECT * FROM [tblRecorded Costs]
WHERE([tblRecorded Costs].Payee = " & Chr(34) & txtPayee.Text & Chr(34) &
")")

For your case

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim NoOfRecords As Long
' Open the database
Set db = OpenDatabase("C:\nihul.mdb")
' Retrieve the recordset
Set rs = db.OpenRecordset("SELECT * FROM expressions
WHERE (expressions.heb = " & Chr(34) & pStr & Chr(34) & ")")
' Determine the number of retrieved records
With rs
.MoveLast
NoOfRecords = .RecordCount
.MoveFirst
End With
' Set the number of Columns = number of Fields in recordset
ListBox1.ColumnCount = rs.Fields.Count
' Load the ListBox with the retrieved records
ListBox1.Column = rs.GetRows(NoOfRecords)
' Cleanup
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing

As mentioned before, you should give names to all of your controls that
indicate both their type and their purpose.
--
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 Doug,

This code is great to fill a listbox without a condition... but... my
problem is that I need to have a condition... I need to find a word inside
a
sentence and not all the sentence...

Greg has suggested :

Sub Whatever()
Dim pStr As String
If InStr(Me.textbox16.Text, "Yo") > 0 Or Instr(Me.textboxt16.Text, "rk") >
0
Then
pStr = "New York City"
End If

This code works great too.... I am failing miserably in combining the two
codes... that is where I'm stuck...

after checking that this condition is true - then start column count...

The second problem is:
I need to show only 2 columns - and not all the columns of the recordset
in
the listbox...

I Hope you can help me with that.

Thank you,

Iris





Doug Robbins - Word MVP said:
In that case, you would use a command button (cmdShowPayments) with the
following code that would load the listbox with the payments made to a
payee
whose name was entered into a textbox control txtPayee

Private Sub cmdShowPayments_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim NoOfRecords As Long
' Open the database
Set db = OpenDatabase("C:\Documents and Settings\Doug Robbins\My
Documents\Cost Database\Cost Control System Back End.mdb")
' Retrieve the recordset
Set rs = db.OpenRecordset("SELECT * FROM [tblRecorded Costs]
WHERE([tblRecorded Costs].Payee = " & Chr(34) & txtPayee.Text & Chr(34) &
")")
' Determine the number of retrieved records
With rs
.MoveLast
NoOfRecords = .RecordCount
.MoveFirst
End With
' Set the number of Columns = number of Fields in recordset
lstPayments.ColumnCount = rs.Fields.Count
' Load the ListBox with the retrieved records
lstPayments.Column = rs.GetRows(NoOfRecords)
' Cleanup
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
End Sub


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

Thank you very much for your answer! :) I appriciate this very much
!!

To populate combobox will be the best and easiest thing to do. But I
need
to
find a word inside the sentence: for example: with a senctence like "I
am
living in New York City"

In a combobox there is no problem if you search from the first word: "I
am...." and so on...

My problem is that I want to search inside the sentence: for example -
the
word "living" - and I want to see all the resaults of this search -
their
could be 20 or more resaults - that is why I need to populate a listbox
with
the resaults...

thank you again for your answer.... I hope you will be able to help me
with
that...

and sorry again for the multiple postings... my mistake...


:

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

In that form I have :
textbox1 - in which i write the string I need to search
optionbutton1 - in which I choose the column I need to search the
string
in
the database
comandbutton1 - to execute the search
listbox1 - in which I need the list of the results to appear

The code I wrote execute the search sucssessfully but I don't know
how
to
build the array for all the resualts.... I only get one resault at a
time
and
eventually - only the last resault appears in the list box.

I need all the resualts to appear in the listbox.

can someone please help me write the code correctly...?

This is the code I wrote:

Private Sub CommandButton1_Click()

Dim dbDatabase As Database
Dim rse As Recordset
Dim rsi 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 myActiveRecord As Recordset
Dim x As Long
x = 0


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 category", vbOKOnly + vbExclamation
d = True
Else
If OptionButton1.Value = True Then

ListBox1.Clear

With rse
Do Until .EOF
eStr = ![heb]
If InStr(![heb], TextBox1.Text) > 0 Then
d = True
i = i + 1
TextBox2.Text = ![heb]
ListBox1.AddItem


Set dbDatabase = OpenDatabase("C:\nihul.mdb")

Set myActiveRecord = myDataBase.OpenRecordset("SELECT * FROM
expressions
WHERE heb = '" & TextBox2.Text & "'", dbOpenForwardOnly)

ListBox1.ColumnCount = myActiveRecord.Fields.Count

Do While Not myActiveRecord.EOF
ListBox1.AddItem
ListBox1.ColumnCount = 7
ListBox1.BoundColumn = 7
ListBox1.ColumnWidths = "4 in;1 in;1 in;1 in;1 in;1 in;0 in;"
ListBox1.List(x, 6) = myActiveRecord.Fields("hebrt")
ListBox1.List(x, 5) = myActiveRecord.Fields("heb")
ListBox1.List(x, 4) = myActiveRecord.Fields("engRT")
ListBox1.List(x, 3) = myActiveRecord.Fields("eng")
ListBox1.List(x, 2) = myActiveRecord.Fields("employeeName")
ListBox1.List(x, 1) = myActiveRecord.Fields("lastUpdate")
ListBox1.List(x, 0) = myActiveRecord.Fields("hebshort")
x = x + x

myActiveRecord.MoveNext
Loop

myActiveRecord.Close
myDataBase.Close
Set myActiveRecord = Nothing
Set myDataBase = Nothing

answer = MsgBox("R U sure?" & TextBox1.Text & ". ,
vbQuestion)
If answer = vbNo Then
Exit Sub
Else
End If
End If
.MoveNext
e = e + 1
Loop
End With
End If
End If
End If

rse.Close
dbDatabase.Close
If d = False Then
MsgBox "no resaults are found", vbOKOnly + vbExclamation
End If

End Sub
 
I

iris

I've changed this line:

Set rs = db.OpenRecordset("SELECT * FROM expressions order by heb WHERE '" &
TextBox2.Text & "' = InStr(![heb], TextBox1.Text)")

and I'm getting this error:
Error 3075 - Syntax error (missing operator) in query expression 'heb WHERE
" = InStr(![heb], Textbox1.Text)'

Do you know where the syntax error is?

Maybe This will solve the problem...



Doug Robbins - Word MVP said:
In that case, you would use a command button (cmdShowPayments) with the
following code that would load the listbox with the payments made to a payee
whose name was entered into a textbox control txtPayee

Private Sub cmdShowPayments_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim NoOfRecords As Long
' Open the database
Set db = OpenDatabase("C:\Documents and Settings\Doug Robbins\My
Documents\Cost Database\Cost Control System Back End.mdb")
' Retrieve the recordset
Set rs = db.OpenRecordset("SELECT * FROM [tblRecorded Costs]
WHERE([tblRecorded Costs].Payee = " & Chr(34) & txtPayee.Text & Chr(34) &
")")
' Determine the number of retrieved records
With rs
.MoveLast
NoOfRecords = .RecordCount
.MoveFirst
End With
' Set the number of Columns = number of Fields in recordset
lstPayments.ColumnCount = rs.Fields.Count
' Load the ListBox with the retrieved records
lstPayments.Column = rs.GetRows(NoOfRecords)
' Cleanup
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
End Sub


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

Thank you very much for your answer! :) I appriciate this very much !!

To populate combobox will be the best and easiest thing to do. But I need
to
find a word inside the sentence: for example: with a senctence like "I am
living in New York City"

In a combobox there is no problem if you search from the first word: "I
am...." and so on...

My problem is that I want to search inside the sentence: for example - the
word "living" - and I want to see all the resaults of this search - their
could be 20 or more resaults - that is why I need to populate a listbox
with
the resaults...

thank you again for your answer.... I hope you will be able to help me
with
that...

and sorry again for the multiple postings... my mistake...


iris said:
I have a userform1 in word that feeds from an access database.

In that form I have :
textbox1 - in which i write the string I need to search
optionbutton1 - in which I choose the column I need to search the string
in
the database
comandbutton1 - to execute the search
listbox1 - in which I need the list of the results to appear

The code I wrote execute the search sucssessfully but I don't know how
to
build the array for all the resualts.... I only get one resault at a time
and
eventually - only the last resault appears in the list box.

I need all the resualts to appear in the listbox.

can someone please help me write the code correctly...?

This is the code I wrote:

Private Sub CommandButton1_Click()

Dim dbDatabase As Database
Dim rse As Recordset
Dim rsi 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 myActiveRecord As Recordset
Dim x As Long
x = 0


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 category", vbOKOnly + vbExclamation
d = True
Else
If OptionButton1.Value = True Then

ListBox1.Clear

With rse
Do Until .EOF
eStr = ![heb]
If InStr(![heb], TextBox1.Text) > 0 Then
d = True
i = i + 1
TextBox2.Text = ![heb]
ListBox1.AddItem


Set dbDatabase = OpenDatabase("C:\nihul.mdb")

Set myActiveRecord = myDataBase.OpenRecordset("SELECT * FROM expressions
WHERE heb = '" & TextBox2.Text & "'", dbOpenForwardOnly)

ListBox1.ColumnCount = myActiveRecord.Fields.Count

Do While Not myActiveRecord.EOF
ListBox1.AddItem
ListBox1.ColumnCount = 7
ListBox1.BoundColumn = 7
ListBox1.ColumnWidths = "4 in;1 in;1 in;1 in;1 in;1 in;0 in;"
ListBox1.List(x, 6) = myActiveRecord.Fields("hebrt")
ListBox1.List(x, 5) = myActiveRecord.Fields("heb")
ListBox1.List(x, 4) = myActiveRecord.Fields("engRT")
ListBox1.List(x, 3) = myActiveRecord.Fields("eng")
ListBox1.List(x, 2) = myActiveRecord.Fields("employeeName")
ListBox1.List(x, 1) = myActiveRecord.Fields("lastUpdate")
ListBox1.List(x, 0) = myActiveRecord.Fields("hebshort")
x = x + x

myActiveRecord.MoveNext
Loop

myActiveRecord.Close
myDataBase.Close
Set myActiveRecord = Nothing
Set myDataBase = Nothing

answer = MsgBox("R U sure?" & TextBox1.Text & ". ,
vbQuestion)
If answer = vbNo Then
Exit Sub
Else
End If
End If
.MoveNext
e = e + 1
Loop
End With
End If
End If
End If

rse.Close
dbDatabase.Close
If d = False Then
MsgBox "no resaults are found", vbOKOnly + vbExclamation
End If

End Sub
 
I

iris

I'm so confused....

the pstr should be the answer to:

If InStr(![heb], TextBox1.Text) > 0 Then
pstr=![heb]
else
end if

but where do I put this code?

whatever I try gets the same error:
"no record have been found"


Doug Robbins - Word MVP said:
In my code, the condition is applied by the WHERE in the following:

Set rs = db.OpenRecordset("SELECT * FROM [tblRecorded Costs]
WHERE([tblRecorded Costs].Payee = " & Chr(34) & txtPayee.Text & Chr(34) &
")")

For your case

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim NoOfRecords As Long
' Open the database
Set db = OpenDatabase("C:\nihul.mdb")
' Retrieve the recordset
Set rs = db.OpenRecordset("SELECT * FROM expressions
WHERE (expressions.heb = " & Chr(34) & pStr & Chr(34) & ")")
' Determine the number of retrieved records
With rs
.MoveLast
NoOfRecords = .RecordCount
.MoveFirst
End With
' Set the number of Columns = number of Fields in recordset
ListBox1.ColumnCount = rs.Fields.Count
' Load the ListBox with the retrieved records
ListBox1.Column = rs.GetRows(NoOfRecords)
' Cleanup
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing

As mentioned before, you should give names to all of your controls that
indicate both their type and their purpose.
--
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 Doug,

This code is great to fill a listbox without a condition... but... my
problem is that I need to have a condition... I need to find a word inside
a
sentence and not all the sentence...

Greg has suggested :

Sub Whatever()
Dim pStr As String
If InStr(Me.textbox16.Text, "Yo") > 0 Or Instr(Me.textboxt16.Text, "rk") >
0
Then
pStr = "New York City"
End If

This code works great too.... I am failing miserably in combining the two
codes... that is where I'm stuck...

after checking that this condition is true - then start column count...

The second problem is:
I need to show only 2 columns - and not all the columns of the recordset
in
the listbox...

I Hope you can help me with that.

Thank you,

Iris





Doug Robbins - Word MVP said:
In that case, you would use a command button (cmdShowPayments) with the
following code that would load the listbox with the payments made to a
payee
whose name was entered into a textbox control txtPayee

Private Sub cmdShowPayments_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim NoOfRecords As Long
' Open the database
Set db = OpenDatabase("C:\Documents and Settings\Doug Robbins\My
Documents\Cost Database\Cost Control System Back End.mdb")
' Retrieve the recordset
Set rs = db.OpenRecordset("SELECT * FROM [tblRecorded Costs]
WHERE([tblRecorded Costs].Payee = " & Chr(34) & txtPayee.Text & Chr(34) &
")")
' Determine the number of retrieved records
With rs
.MoveLast
NoOfRecords = .RecordCount
.MoveFirst
End With
' Set the number of Columns = number of Fields in recordset
lstPayments.ColumnCount = rs.Fields.Count
' Load the ListBox with the retrieved records
lstPayments.Column = rs.GetRows(NoOfRecords)
' Cleanup
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
End Sub


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

Hi Doug,

Thank you very much for your answer! :) I appriciate this very much
!!

To populate combobox will be the best and easiest thing to do. But I
need
to
find a word inside the sentence: for example: with a senctence like "I
am
living in New York City"

In a combobox there is no problem if you search from the first word: "I
am...." and so on...

My problem is that I want to search inside the sentence: for example -
the
word "living" - and I want to see all the resaults of this search -
their
could be 20 or more resaults - that is why I need to populate a listbox
with
the resaults...

thank you again for your answer.... I hope you will be able to help me
with
that...

and sorry again for the multiple postings... my mistake...


:

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

In that form I have :
textbox1 - in which i write the string I need to search
optionbutton1 - in which I choose the column I need to search the
string
in
the database
comandbutton1 - to execute the search
listbox1 - in which I need the list of the results to appear

The code I wrote execute the search sucssessfully but I don't know
how
to
build the array for all the resualts.... I only get one resault at a
time
and
eventually - only the last resault appears in the list box.

I need all the resualts to appear in the listbox.

can someone please help me write the code correctly...?

This is the code I wrote:

Private Sub CommandButton1_Click()

Dim dbDatabase As Database
Dim rse As Recordset
Dim rsi 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 myActiveRecord As Recordset
Dim x As Long
x = 0


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 category", vbOKOnly + vbExclamation
d = True
Else
If OptionButton1.Value = True Then

ListBox1.Clear

With rse
Do Until .EOF
eStr = ![heb]
If InStr(![heb], TextBox1.Text) > 0 Then
d = True
i = i + 1
TextBox2.Text = ![heb]
ListBox1.AddItem


Set dbDatabase = OpenDatabase("C:\nihul.mdb")

Set myActiveRecord = myDataBase.OpenRecordset("SELECT * FROM
expressions
WHERE heb = '" & TextBox2.Text & "'", dbOpenForwardOnly)

ListBox1.ColumnCount = myActiveRecord.Fields.Count

Do While Not myActiveRecord.EOF
ListBox1.AddItem
ListBox1.ColumnCount = 7
ListBox1.BoundColumn = 7
ListBox1.ColumnWidths = "4 in;1 in;1 in;1 in;1 in;1 in;0 in;"
ListBox1.List(x, 6) = myActiveRecord.Fields("hebrt")
ListBox1.List(x, 5) = myActiveRecord.Fields("heb")
ListBox1.List(x, 4) = myActiveRecord.Fields("engRT")
ListBox1.List(x, 3) = myActiveRecord.Fields("eng")
ListBox1.List(x, 2) = myActiveRecord.Fields("employeeName")
ListBox1.List(x, 1) = myActiveRecord.Fields("lastUpdate")
ListBox1.List(x, 0) = myActiveRecord.Fields("hebshort")
x = x + x

myActiveRecord.MoveNext
Loop

myActiveRecord.Close
myDataBase.Close
Set myActiveRecord = Nothing
Set myDataBase = Nothing

answer = MsgBox("R U sure?" & TextBox1.Text & ". ,
vbQuestion)
If answer = vbNo Then
Exit Sub
Else
End If
End If
.MoveNext
e = e + 1
Loop
End With
End If
End If
End If

rse.Close
dbDatabase.Close
If d = False Then
MsgBox "no resaults are found", vbOKOnly + vbExclamation
End If

End Sub
 
I

iris

Hi Doug,

Problem SOLVED!!!!

Thank you for everything!!

Iris

Doug Robbins - Word MVP said:
In my code, the condition is applied by the WHERE in the following:

Set rs = db.OpenRecordset("SELECT * FROM [tblRecorded Costs]
WHERE([tblRecorded Costs].Payee = " & Chr(34) & txtPayee.Text & Chr(34) &
")")

For your case

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim NoOfRecords As Long
' Open the database
Set db = OpenDatabase("C:\nihul.mdb")
' Retrieve the recordset
Set rs = db.OpenRecordset("SELECT * FROM expressions
WHERE (expressions.heb = " & Chr(34) & pStr & Chr(34) & ")")
' Determine the number of retrieved records
With rs
.MoveLast
NoOfRecords = .RecordCount
.MoveFirst
End With
' Set the number of Columns = number of Fields in recordset
ListBox1.ColumnCount = rs.Fields.Count
' Load the ListBox with the retrieved records
ListBox1.Column = rs.GetRows(NoOfRecords)
' Cleanup
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing

As mentioned before, you should give names to all of your controls that
indicate both their type and their purpose.
--
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 Doug,

This code is great to fill a listbox without a condition... but... my
problem is that I need to have a condition... I need to find a word inside
a
sentence and not all the sentence...

Greg has suggested :

Sub Whatever()
Dim pStr As String
If InStr(Me.textbox16.Text, "Yo") > 0 Or Instr(Me.textboxt16.Text, "rk") >
0
Then
pStr = "New York City"
End If

This code works great too.... I am failing miserably in combining the two
codes... that is where I'm stuck...

after checking that this condition is true - then start column count...

The second problem is:
I need to show only 2 columns - and not all the columns of the recordset
in
the listbox...

I Hope you can help me with that.

Thank you,

Iris





Doug Robbins - Word MVP said:
In that case, you would use a command button (cmdShowPayments) with the
following code that would load the listbox with the payments made to a
payee
whose name was entered into a textbox control txtPayee

Private Sub cmdShowPayments_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim NoOfRecords As Long
' Open the database
Set db = OpenDatabase("C:\Documents and Settings\Doug Robbins\My
Documents\Cost Database\Cost Control System Back End.mdb")
' Retrieve the recordset
Set rs = db.OpenRecordset("SELECT * FROM [tblRecorded Costs]
WHERE([tblRecorded Costs].Payee = " & Chr(34) & txtPayee.Text & Chr(34) &
")")
' Determine the number of retrieved records
With rs
.MoveLast
NoOfRecords = .RecordCount
.MoveFirst
End With
' Set the number of Columns = number of Fields in recordset
lstPayments.ColumnCount = rs.Fields.Count
' Load the ListBox with the retrieved records
lstPayments.Column = rs.GetRows(NoOfRecords)
' Cleanup
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
End Sub


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

Hi Doug,

Thank you very much for your answer! :) I appriciate this very much
!!

To populate combobox will be the best and easiest thing to do. But I
need
to
find a word inside the sentence: for example: with a senctence like "I
am
living in New York City"

In a combobox there is no problem if you search from the first word: "I
am...." and so on...

My problem is that I want to search inside the sentence: for example -
the
word "living" - and I want to see all the resaults of this search -
their
could be 20 or more resaults - that is why I need to populate a listbox
with
the resaults...

thank you again for your answer.... I hope you will be able to help me
with
that...

and sorry again for the multiple postings... my mistake...


:

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

In that form I have :
textbox1 - in which i write the string I need to search
optionbutton1 - in which I choose the column I need to search the
string
in
the database
comandbutton1 - to execute the search
listbox1 - in which I need the list of the results to appear

The code I wrote execute the search sucssessfully but I don't know
how
to
build the array for all the resualts.... I only get one resault at a
time
and
eventually - only the last resault appears in the list box.

I need all the resualts to appear in the listbox.

can someone please help me write the code correctly...?

This is the code I wrote:

Private Sub CommandButton1_Click()

Dim dbDatabase As Database
Dim rse As Recordset
Dim rsi 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 myActiveRecord As Recordset
Dim x As Long
x = 0


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 category", vbOKOnly + vbExclamation
d = True
Else
If OptionButton1.Value = True Then

ListBox1.Clear

With rse
Do Until .EOF
eStr = ![heb]
If InStr(![heb], TextBox1.Text) > 0 Then
d = True
i = i + 1
TextBox2.Text = ![heb]
ListBox1.AddItem


Set dbDatabase = OpenDatabase("C:\nihul.mdb")

Set myActiveRecord = myDataBase.OpenRecordset("SELECT * FROM
expressions
WHERE heb = '" & TextBox2.Text & "'", dbOpenForwardOnly)

ListBox1.ColumnCount = myActiveRecord.Fields.Count

Do While Not myActiveRecord.EOF
ListBox1.AddItem
ListBox1.ColumnCount = 7
ListBox1.BoundColumn = 7
ListBox1.ColumnWidths = "4 in;1 in;1 in;1 in;1 in;1 in;0 in;"
ListBox1.List(x, 6) = myActiveRecord.Fields("hebrt")
ListBox1.List(x, 5) = myActiveRecord.Fields("heb")
ListBox1.List(x, 4) = myActiveRecord.Fields("engRT")
ListBox1.List(x, 3) = myActiveRecord.Fields("eng")
ListBox1.List(x, 2) = myActiveRecord.Fields("employeeName")
ListBox1.List(x, 1) = myActiveRecord.Fields("lastUpdate")
ListBox1.List(x, 0) = myActiveRecord.Fields("hebshort")
x = x + x

myActiveRecord.MoveNext
Loop

myActiveRecord.Close
myDataBase.Close
Set myActiveRecord = Nothing
Set myDataBase = Nothing

answer = MsgBox("R U sure?" & TextBox1.Text & ". ,
vbQuestion)
If answer = vbNo Then
Exit Sub
Else
End If
End If
.MoveNext
e = e + 1
Loop
End With
End If
End If
End If

rse.Close
dbDatabase.Close
If d = False Then
MsgBox "no resaults are found", vbOKOnly + vbExclamation
End If

End Sub
 
I

iris

Hi Gordon,

Problem SOLVED!!!

Just wanted to fill you up.... :) :)


Gordon Bentley-Mix said:
Doug,

" I will ... fill you up tomorrow."

Who's a lucky boy then? ;-P
--
Cheers!

Gordon Bentley-Mix
Word MVP

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


iris said:
Thank you so much Doug!

I will try it and fill you up tomorrow.
It is now 2:30 (17/2) am and I am working on this since 06:00 (16/2)...

I hardli open my eyes....

Good night and trully trully thank you for your wilingness to help!!!

Talk to you tomorrow... :)


iris said:
Hi Doug,

Thank you very much for your answer! :) I appriciate this very much !!

To populate combobox will be the best and easiest thing to do. But I need to
find a word inside the sentence: for example: with a senctence like "I am
living in New York City"

In a combobox there is no problem if you search from the first word: "I
am...." and so on...

My problem is that I want to search inside the sentence: for example - the
word "living" - and I want to see all the resaults of this search - their
could be 20 or more resaults - that is why I need to populate a listbox with
the resaults...

thank you again for your answer.... I hope you will be able to help me with
that...

and sorry again for the multiple postings... my mistake...


:

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

In that form I have :
textbox1 - in which i write the string I need to search
optionbutton1 - in which I choose the column I need to search the string in
the database
comandbutton1 - to execute the search
listbox1 - in which I need the list of the results to appear

The code I wrote execute the search sucssessfully but I don't know how to
build the array for all the resualts.... I only get one resault at a time and
eventually - only the last resault appears in the list box.

I need all the resualts to appear in the listbox.

can someone please help me write the code correctly...?

This is the code I wrote:

Private Sub CommandButton1_Click()

Dim dbDatabase As Database
Dim rse As Recordset
Dim rsi 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 myActiveRecord As Recordset
Dim x As Long
x = 0


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 category", vbOKOnly + vbExclamation
d = True
Else
If OptionButton1.Value = True Then

ListBox1.Clear

With rse
Do Until .EOF
eStr = ![heb]
If InStr(![heb], TextBox1.Text) > 0 Then
d = True
i = i + 1
TextBox2.Text = ![heb]
ListBox1.AddItem


Set dbDatabase = OpenDatabase("C:\nihul.mdb")

Set myActiveRecord = myDataBase.OpenRecordset("SELECT * FROM expressions
WHERE heb = '" & TextBox2.Text & "'", dbOpenForwardOnly)

ListBox1.ColumnCount = myActiveRecord.Fields.Count

Do While Not myActiveRecord.EOF
ListBox1.AddItem
ListBox1.ColumnCount = 7
ListBox1.BoundColumn = 7
ListBox1.ColumnWidths = "4 in;1 in;1 in;1 in;1 in;1 in;0 in;"
ListBox1.List(x, 6) = myActiveRecord.Fields("hebrt")
ListBox1.List(x, 5) = myActiveRecord.Fields("heb")
ListBox1.List(x, 4) = myActiveRecord.Fields("engRT")
ListBox1.List(x, 3) = myActiveRecord.Fields("eng")
ListBox1.List(x, 2) = myActiveRecord.Fields("employeeName")
ListBox1.List(x, 1) = myActiveRecord.Fields("lastUpdate")
ListBox1.List(x, 0) = myActiveRecord.Fields("hebshort")
x = x + x

myActiveRecord.MoveNext
Loop

myActiveRecord.Close
myDataBase.Close
Set myActiveRecord = Nothing
Set myDataBase = Nothing

answer = MsgBox("R U sure?" & TextBox1.Text & ". ,
vbQuestion)
If answer = vbNo Then
Exit Sub
Else
End If
End If
.MoveNext
e = e + 1
Loop
End With
End If
End If
End If

rse.Close
dbDatabase.Close
If d = False Then
MsgBox "no resaults are found", vbOKOnly + vbExclamation
End If

End Sub
 
G

Gordon Bentley-Mix

Don't change a thing Iris. I think it's just gorgeous, and your message
still gets across - which is more that I can say about *some* of the posts
I've seen.
--
Cheers!

Gordon Bentley-Mix
Word MVP

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


iris said:
Oooooooohhhhhh.... I gess I wrote this wrong havn't I Gordon...:)

But... If it maid you lough.... It's the least I can do....

I must work on my English.... a second after I'll finish this thing....

Cheers to you to...



Gordon Bentley-Mix said:
Doug,

" I will ... fill you up tomorrow."

Who's a lucky boy then? ;-P
--
Cheers!

Gordon Bentley-Mix
Word MVP

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


iris said:
Thank you so much Doug!

I will try it and fill you up tomorrow.
It is now 2:30 (17/2) am and I am working on this since 06:00 (16/2)...

I hardli open my eyes....

Good night and trully trully thank you for your wilingness to help!!!

Talk to you tomorrow... :)


:

Hi Doug,

Thank you very much for your answer! :) I appriciate this very much
!!

To populate combobox will be the best and easiest thing to do. But I
need to
find a word inside the sentence: for example: with a senctence like
"I am
living in New York City"

In a combobox there is no problem if you search from the first word:
"I
am...." and so on...

My problem is that I want to search inside the sentence: for
example - the
word "living" - and I want to see all the resaults of this search -
their
could be 20 or more resaults - that is why I need to populate a
listbox with
the resaults...

thank you again for your answer.... I hope you will be able to help
me with
that...

and sorry again for the multiple postings... my mistake...


:

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

In that form I have :
textbox1 - in which i write the string I need to search
optionbutton1 - in which I choose the column I need to search the
string in
the database
comandbutton1 - to execute the search
listbox1 - in which I need the list of the results to appear

The code I wrote execute the search sucssessfully but I don't know
how to
build the array for all the resualts.... I only get one resault at
a time and
eventually - only the last resault appears in the list box.

I need all the resualts to appear in the listbox.

can someone please help me write the code correctly...?

This is the code I wrote:

Private Sub CommandButton1_Click()

Dim dbDatabase As Database
Dim rse As Recordset
Dim rsi 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 myActiveRecord As Recordset
Dim x As Long
x = 0


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 category", vbOKOnly + vbExclamation
d = True
Else
If OptionButton1.Value = True Then

ListBox1.Clear

With rse
Do Until .EOF
eStr = ![heb]
If InStr(![heb], TextBox1.Text) > 0 Then
d = True
i = i + 1
TextBox2.Text = ![heb]
ListBox1.AddItem


Set dbDatabase = OpenDatabase("C:\nihul.mdb")

Set myActiveRecord = myDataBase.OpenRecordset("SELECT * FROM
expressions
WHERE heb = '" & TextBox2.Text & "'", dbOpenForwardOnly)

ListBox1.ColumnCount = myActiveRecord.Fields.Count

Do While Not myActiveRecord.EOF
ListBox1.AddItem
ListBox1.ColumnCount = 7
ListBox1.BoundColumn = 7
ListBox1.ColumnWidths = "4 in;1 in;1 in;1 in;1 in;1 in;0
in;"
ListBox1.List(x, 6) = myActiveRecord.Fields("hebrt")
ListBox1.List(x, 5) = myActiveRecord.Fields("heb")
ListBox1.List(x, 4) = myActiveRecord.Fields("engRT")
ListBox1.List(x, 3) = myActiveRecord.Fields("eng")
ListBox1.List(x, 2) = myActiveRecord.Fields("employeeName")
ListBox1.List(x, 1) = myActiveRecord.Fields("lastUpdate")
ListBox1.List(x, 0) = myActiveRecord.Fields("hebshort")
x = x + x

myActiveRecord.MoveNext
Loop

myActiveRecord.Close
myDataBase.Close
Set myActiveRecord = Nothing
Set myDataBase = Nothing

answer = MsgBox("R U sure?" & TextBox1.Text &
". ,
vbQuestion)
If answer = vbNo Then
Exit Sub
Else
End If
End If
.MoveNext
e = e + 1
Loop
End With
End If
End If
End If

rse.Close
dbDatabase.Close
If d = False Then
MsgBox "no resaults are found", vbOKOnly +
vbExclamation
End If

End Sub
 
I

iris

Hi Gordon,

As long as we are amused and laughing - then all is good in the world....
well... almost all.... which is also nice :)

A question:

I need a macro to check if a document is open, regardless what it's name
is....

I knwo it sounds weird , but there are cases in wich the word application is
open - but there isn't a document open.... I need to check if there is an
open document - without checking it's name...

Have any Idea?


Gordon Bentley-Mix said:
Don't change a thing Iris. I think it's just gorgeous, and your message
still gets across - which is more that I can say about *some* of the posts
I've seen.
--
Cheers!

Gordon Bentley-Mix
Word MVP

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


iris said:
Oooooooohhhhhh.... I gess I wrote this wrong havn't I Gordon...:)

But... If it maid you lough.... It's the least I can do....

I must work on my English.... a second after I'll finish this thing....

Cheers to you to...



Gordon Bentley-Mix said:
Doug,

" I will ... fill you up tomorrow."

Who's a lucky boy then? ;-P
--
Cheers!

Gordon Bentley-Mix
Word MVP

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


:

Thank you so much Doug!

I will try it and fill you up tomorrow.
It is now 2:30 (17/2) am and I am working on this since 06:00 (16/2)...

I hardli open my eyes....

Good night and trully trully thank you for your wilingness to help!!!

Talk to you tomorrow... :)


:

Hi Doug,

Thank you very much for your answer! :) I appriciate this very much
!!

To populate combobox will be the best and easiest thing to do. But I
need to
find a word inside the sentence: for example: with a senctence like
"I am
living in New York City"

In a combobox there is no problem if you search from the first word:
"I
am...." and so on...

My problem is that I want to search inside the sentence: for
example - the
word "living" - and I want to see all the resaults of this search -
their
could be 20 or more resaults - that is why I need to populate a
listbox with
the resaults...

thank you again for your answer.... I hope you will be able to help
me with
that...

and sorry again for the multiple postings... my mistake...


:

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

In that form I have :
textbox1 - in which i write the string I need to search
optionbutton1 - in which I choose the column I need to search the
string in
the database
comandbutton1 - to execute the search
listbox1 - in which I need the list of the results to appear

The code I wrote execute the search sucssessfully but I don't know
how to
build the array for all the resualts.... I only get one resault at
a time and
eventually - only the last resault appears in the list box.

I need all the resualts to appear in the listbox.

can someone please help me write the code correctly...?

This is the code I wrote:

Private Sub CommandButton1_Click()

Dim dbDatabase As Database
Dim rse As Recordset
Dim rsi 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 myActiveRecord As Recordset
Dim x As Long
x = 0


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 category", vbOKOnly + vbExclamation
d = True
Else
If OptionButton1.Value = True Then

ListBox1.Clear

With rse
Do Until .EOF
eStr = ![heb]
If InStr(![heb], TextBox1.Text) > 0 Then
d = True
i = i + 1
TextBox2.Text = ![heb]
ListBox1.AddItem


Set dbDatabase = OpenDatabase("C:\nihul.mdb")

Set myActiveRecord = myDataBase.OpenRecordset("SELECT * FROM
expressions
WHERE heb = '" & TextBox2.Text & "'", dbOpenForwardOnly)

ListBox1.ColumnCount = myActiveRecord.Fields.Count

Do While Not myActiveRecord.EOF
ListBox1.AddItem
ListBox1.ColumnCount = 7
ListBox1.BoundColumn = 7
ListBox1.ColumnWidths = "4 in;1 in;1 in;1 in;1 in;1 in;0
in;"
ListBox1.List(x, 6) = myActiveRecord.Fields("hebrt")
ListBox1.List(x, 5) = myActiveRecord.Fields("heb")
ListBox1.List(x, 4) = myActiveRecord.Fields("engRT")
ListBox1.List(x, 3) = myActiveRecord.Fields("eng")
ListBox1.List(x, 2) = myActiveRecord.Fields("employeeName")
ListBox1.List(x, 1) = myActiveRecord.Fields("lastUpdate")
ListBox1.List(x, 0) = myActiveRecord.Fields("hebshort")
x = x + x

myActiveRecord.MoveNext
Loop

myActiveRecord.Close
myDataBase.Close
Set myActiveRecord = Nothing
Set myDataBase = Nothing

answer = MsgBox("R U sure?" & TextBox1.Text &
". ,
vbQuestion)
If answer = vbNo Then
Exit Sub
Else
End If
End If
.MoveNext
e = e + 1
Loop
End With
End If
End If
End If

rse.Close
dbDatabase.Close
If d = False Then
MsgBox "no resaults are found", vbOKOnly +
vbExclamation
End If

End Sub
 
G

Gordon Bentley-Mix

Iris,

What you want to check is the Count property of the Documents collection;
e.g.:

If Documents.Count > 0 Then
'Do whatever you want to do when there is at least one document open
Else
'Do whatever you want to do when there are NO documents open - like display
a message box perhaps?
End If

And it doesn't sound strange at all. This is something I've done many times
before.
--
Cheers!

Gordon Bentley-Mix
Word MVP

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


iris said:
Hi Gordon,

As long as we are amused and laughing - then all is good in the world....
well... almost all.... which is also nice :)

A question:

I need a macro to check if a document is open, regardless what it's name
is....

I knwo it sounds weird , but there are cases in wich the word application
is
open - but there isn't a document open.... I need to check if there is an
open document - without checking it's name...

Have any Idea?


Gordon Bentley-Mix said:
Don't change a thing Iris. I think it's just gorgeous, and your message
still gets across - which is more that I can say about *some* of the
posts
I've seen.
--
Cheers!

Gordon Bentley-Mix
Word MVP

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


iris said:
Oooooooohhhhhh.... I gess I wrote this wrong havn't I Gordon...:)

But... If it maid you lough.... It's the least I can do....

I must work on my English.... a second after I'll finish this thing....

Cheers to you to...



:

Doug,

" I will ... fill you up tomorrow."

Who's a lucky boy then? ;-P
--
Cheers!

Gordon Bentley-Mix
Word MVP

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


:

Thank you so much Doug!

I will try it and fill you up tomorrow.
It is now 2:30 (17/2) am and I am working on this since 06:00
(16/2)...

I hardli open my eyes....

Good night and trully trully thank you for your wilingness to
help!!!

Talk to you tomorrow... :)


:

Hi Doug,

Thank you very much for your answer! :) I appriciate this very
much
!!

To populate combobox will be the best and easiest thing to do. But
I
need to
find a word inside the sentence: for example: with a senctence
like
"I am
living in New York City"

In a combobox there is no problem if you search from the first
word:
"I
am...." and so on...

My problem is that I want to search inside the sentence: for
example - the
word "living" - and I want to see all the resaults of this
search -
their
could be 20 or more resaults - that is why I need to populate a
listbox with
the resaults...

thank you again for your answer.... I hope you will be able to
help
me with
that...

and sorry again for the multiple postings... my mistake...


:

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

In that form I have :
textbox1 - in which i write the string I need to search
optionbutton1 - in which I choose the column I need to search
the
string in
the database
comandbutton1 - to execute the search
listbox1 - in which I need the list of the results to appear

The code I wrote execute the search sucssessfully but I don't
know
how to
build the array for all the resualts.... I only get one resault
at
a time and
eventually - only the last resault appears in the list box.

I need all the resualts to appear in the listbox.

can someone please help me write the code correctly...?

This is the code I wrote:

Private Sub CommandButton1_Click()

Dim dbDatabase As Database
Dim rse As Recordset
Dim rsi 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 myActiveRecord As Recordset
Dim x As Long
x = 0


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 category", vbOKOnly + vbExclamation
d = True
Else
If OptionButton1.Value = True Then

ListBox1.Clear

With rse
Do Until .EOF
eStr = ![heb]
If InStr(![heb], TextBox1.Text) > 0 Then
d = True
i = i + 1
TextBox2.Text = ![heb]
ListBox1.AddItem


Set dbDatabase = OpenDatabase("C:\nihul.mdb")

Set myActiveRecord = myDataBase.OpenRecordset("SELECT * FROM
expressions
WHERE heb = '" & TextBox2.Text & "'", dbOpenForwardOnly)

ListBox1.ColumnCount = myActiveRecord.Fields.Count

Do While Not myActiveRecord.EOF
ListBox1.AddItem
ListBox1.ColumnCount = 7
ListBox1.BoundColumn = 7
ListBox1.ColumnWidths = "4 in;1 in;1 in;1 in;1 in;1 in;0
in;"
ListBox1.List(x, 6) = myActiveRecord.Fields("hebrt")
ListBox1.List(x, 5) = myActiveRecord.Fields("heb")
ListBox1.List(x, 4) = myActiveRecord.Fields("engRT")
ListBox1.List(x, 3) = myActiveRecord.Fields("eng")
ListBox1.List(x, 2) = myActiveRecord.Fields("employeeName")
ListBox1.List(x, 1) = myActiveRecord.Fields("lastUpdate")
ListBox1.List(x, 0) = myActiveRecord.Fields("hebshort")
x = x + x

myActiveRecord.MoveNext
Loop

myActiveRecord.Close
myDataBase.Close
Set myActiveRecord = Nothing
Set myDataBase = Nothing

answer = MsgBox("R U sure?" & TextBox1.Text
&
". ,
vbQuestion)
If answer = vbNo Then
Exit Sub
Else
End If
End If
.MoveNext
e = e + 1
Loop
End With
End If
End If
End If

rse.Close
dbDatabase.Close
If d = False Then
MsgBox "no resaults are found", vbOKOnly +
vbExclamation
End If

End Sub
 
I

iris

Thank you very mush Gordon!

HAVE A GREAT DAY!!!

Gordon Bentley-Mix said:
Iris,

What you want to check is the Count property of the Documents collection;
e.g.:

If Documents.Count > 0 Then
'Do whatever you want to do when there is at least one document open
Else
'Do whatever you want to do when there are NO documents open - like display
a message box perhaps?
End If

And it doesn't sound strange at all. This is something I've done many times
before.
--
Cheers!

Gordon Bentley-Mix
Word MVP

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


iris said:
Hi Gordon,

As long as we are amused and laughing - then all is good in the world....
well... almost all.... which is also nice :)

A question:

I need a macro to check if a document is open, regardless what it's name
is....

I knwo it sounds weird , but there are cases in wich the word application
is
open - but there isn't a document open.... I need to check if there is an
open document - without checking it's name...

Have any Idea?


Gordon Bentley-Mix said:
Don't change a thing Iris. I think it's just gorgeous, and your message
still gets across - which is more that I can say about *some* of the
posts
I've seen.
--
Cheers!

Gordon Bentley-Mix
Word MVP

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


Oooooooohhhhhh.... I gess I wrote this wrong havn't I Gordon...:)

But... If it maid you lough.... It's the least I can do....

I must work on my English.... a second after I'll finish this thing....

Cheers to you to...



:

Doug,

" I will ... fill you up tomorrow."

Who's a lucky boy then? ;-P
--
Cheers!

Gordon Bentley-Mix
Word MVP

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


:

Thank you so much Doug!

I will try it and fill you up tomorrow.
It is now 2:30 (17/2) am and I am working on this since 06:00
(16/2)...

I hardli open my eyes....

Good night and trully trully thank you for your wilingness to
help!!!

Talk to you tomorrow... :)


:

Hi Doug,

Thank you very much for your answer! :) I appriciate this very
much
!!

To populate combobox will be the best and easiest thing to do. But
I
need to
find a word inside the sentence: for example: with a senctence
like
"I am
living in New York City"

In a combobox there is no problem if you search from the first
word:
"I
am...." and so on...

My problem is that I want to search inside the sentence: for
example - the
word "living" - and I want to see all the resaults of this
search -
their
could be 20 or more resaults - that is why I need to populate a
listbox with
the resaults...

thank you again for your answer.... I hope you will be able to
help
me with
that...

and sorry again for the multiple postings... my mistake...


:

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

In that form I have :
textbox1 - in which i write the string I need to search
optionbutton1 - in which I choose the column I need to search
the
string in
the database
comandbutton1 - to execute the search
listbox1 - in which I need the list of the results to appear

The code I wrote execute the search sucssessfully but I don't
know
how to
build the array for all the resualts.... I only get one resault
at
a time and
eventually - only the last resault appears in the list box.

I need all the resualts to appear in the listbox.

can someone please help me write the code correctly...?

This is the code I wrote:

Private Sub CommandButton1_Click()

Dim dbDatabase As Database
Dim rse As Recordset
Dim rsi 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 myActiveRecord As Recordset
Dim x As Long
x = 0


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 category", vbOKOnly + vbExclamation
d = True
Else
If OptionButton1.Value = True Then

ListBox1.Clear

With rse
Do Until .EOF
eStr = ![heb]
If InStr(![heb], TextBox1.Text) > 0 Then
d = True
i = i + 1
TextBox2.Text = ![heb]
ListBox1.AddItem


Set dbDatabase = OpenDatabase("C:\nihul.mdb")

Set myActiveRecord = myDataBase.OpenRecordset("SELECT * FROM
expressions
WHERE heb = '" & TextBox2.Text & "'", dbOpenForwardOnly)

ListBox1.ColumnCount = myActiveRecord.Fields.Count

Do While Not myActiveRecord.EOF
ListBox1.AddItem
ListBox1.ColumnCount = 7
ListBox1.BoundColumn = 7
ListBox1.ColumnWidths = "4 in;1 in;1 in;1 in;1 in;1 in;0
in;"
ListBox1.List(x, 6) = myActiveRecord.Fields("hebrt")
ListBox1.List(x, 5) = myActiveRecord.Fields("heb")
ListBox1.List(x, 4) = myActiveRecord.Fields("engRT")
ListBox1.List(x, 3) = myActiveRecord.Fields("eng")
ListBox1.List(x, 2) = myActiveRecord.Fields("employeeName")
ListBox1.List(x, 1) = myActiveRecord.Fields("lastUpdate")
ListBox1.List(x, 0) = myActiveRecord.Fields("hebshort")
x = x + x

myActiveRecord.MoveNext
Loop

myActiveRecord.Close
myDataBase.Close
Set myActiveRecord = Nothing
Set myDataBase = Nothing

answer = MsgBox("R U sure?" & TextBox1.Text
&
". ,
vbQuestion)
If answer = vbNo Then
Exit Sub
Else
End If
End If
.MoveNext
e = e + 1
Loop
End With
End If
End If
End If

rse.Close
dbDatabase.Close
If d = False Then
MsgBox "no resaults are found", vbOKOnly +
vbExclamation
End If

End Sub
 
D

Doug Robbins - Word MVP

Oh, we're getting a bit mushy now.

--
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:
Thank you very mush Gordon!

HAVE A GREAT DAY!!!

Gordon Bentley-Mix said:
Iris,

What you want to check is the Count property of the Documents collection;
e.g.:

If Documents.Count > 0 Then
'Do whatever you want to do when there is at least one document open
Else
'Do whatever you want to do when there are NO documents open - like
display
a message box perhaps?
End If

And it doesn't sound strange at all. This is something I've done many
times
before.
--
Cheers!

Gordon Bentley-Mix
Word MVP

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


iris said:
Hi Gordon,

As long as we are amused and laughing - then all is good in the
world....
well... almost all.... which is also nice :)

A question:

I need a macro to check if a document is open, regardless what it's
name
is....

I knwo it sounds weird , but there are cases in wich the word
application
is
open - but there isn't a document open.... I need to check if there is
an
open document - without checking it's name...

Have any Idea?


:

Don't change a thing Iris. I think it's just gorgeous, and your
message
still gets across - which is more that I can say about *some* of the
posts
I've seen.
--
Cheers!

Gordon Bentley-Mix
Word MVP

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


Oooooooohhhhhh.... I gess I wrote this wrong havn't I Gordon...:)

But... If it maid you lough.... It's the least I can do....

I must work on my English.... a second after I'll finish this
thing....

Cheers to you to...



:

Doug,

" I will ... fill you up tomorrow."

Who's a lucky boy then? ;-P
--
Cheers!

Gordon Bentley-Mix
Word MVP

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


:

Thank you so much Doug!

I will try it and fill you up tomorrow.
It is now 2:30 (17/2) am and I am working on this since 06:00
(16/2)...

I hardli open my eyes....

Good night and trully trully thank you for your wilingness to
help!!!

Talk to you tomorrow... :)


:

Hi Doug,

Thank you very much for your answer! :) I appriciate this
very
much
!!

To populate combobox will be the best and easiest thing to do.
But
I
need to
find a word inside the sentence: for example: with a senctence
like
"I am
living in New York City"

In a combobox there is no problem if you search from the first
word:
"I
am...." and so on...

My problem is that I want to search inside the sentence: for
example - the
word "living" - and I want to see all the resaults of this
search -
their
could be 20 or more resaults - that is why I need to populate a
listbox with
the resaults...

thank you again for your answer.... I hope you will be able to
help
me with
that...

and sorry again for the multiple postings... my mistake...


:

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

In that form I have :
textbox1 - in which i write the string I need to search
optionbutton1 - in which I choose the column I need to search
the
string in
the database
comandbutton1 - to execute the search
listbox1 - in which I need the list of the results to appear

The code I wrote execute the search sucssessfully but I
don't
know
how to
build the array for all the resualts.... I only get one
resault
at
a time and
eventually - only the last resault appears in the list box.

I need all the resualts to appear in the listbox.

can someone please help me write the code correctly...?

This is the code I wrote:

Private Sub CommandButton1_Click()

Dim dbDatabase As Database
Dim rse As Recordset
Dim rsi 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 myActiveRecord As Recordset
Dim x As Long
x = 0


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 category", vbOKOnly +
vbExclamation
d = True
Else
If OptionButton1.Value = True Then

ListBox1.Clear

With rse
Do Until .EOF
eStr = ![heb]
If InStr(![heb], TextBox1.Text) > 0 Then
d = True
i = i + 1
TextBox2.Text = ![heb]
ListBox1.AddItem


Set dbDatabase = OpenDatabase("C:\nihul.mdb")

Set myActiveRecord = myDataBase.OpenRecordset("SELECT * FROM
expressions
WHERE heb = '" & TextBox2.Text & "'", dbOpenForwardOnly)

ListBox1.ColumnCount = myActiveRecord.Fields.Count

Do While Not myActiveRecord.EOF
ListBox1.AddItem
ListBox1.ColumnCount = 7
ListBox1.BoundColumn = 7
ListBox1.ColumnWidths = "4 in;1 in;1 in;1 in;1 in;1
in;0
in;"
ListBox1.List(x, 6) = myActiveRecord.Fields("hebrt")
ListBox1.List(x, 5) = myActiveRecord.Fields("heb")
ListBox1.List(x, 4) = myActiveRecord.Fields("engRT")
ListBox1.List(x, 3) = myActiveRecord.Fields("eng")
ListBox1.List(x, 2) =
myActiveRecord.Fields("employeeName")
ListBox1.List(x, 1) = myActiveRecord.Fields("lastUpdate")
ListBox1.List(x, 0) = myActiveRecord.Fields("hebshort")
x = x + x

myActiveRecord.MoveNext
Loop

myActiveRecord.Close
myDataBase.Close
Set myActiveRecord = Nothing
Set myDataBase = Nothing

answer = MsgBox("R U sure?" &
TextBox1.Text
&
". ,
vbQuestion)
If answer = vbNo Then
Exit Sub
Else
End If
End If
.MoveNext
e = e + 1
Loop
End With
End If
End If
End If

rse.Close
dbDatabase.Close
If d = False Then
MsgBox "no resaults are found", vbOKOnly +
vbExclamation
End If

End Sub
 
I

iris

It's good for ua

Doug Robbins - Word MVP said:
Oh, we're getting a bit mushy now.

--
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:
Thank you very mush Gordon!

HAVE A GREAT DAY!!!

Gordon Bentley-Mix said:
Iris,

What you want to check is the Count property of the Documents collection;
e.g.:

If Documents.Count > 0 Then
'Do whatever you want to do when there is at least one document open
Else
'Do whatever you want to do when there are NO documents open - like
display
a message box perhaps?
End If

And it doesn't sound strange at all. This is something I've done many
times
before.
--
Cheers!

Gordon Bentley-Mix
Word MVP

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


Hi Gordon,

As long as we are amused and laughing - then all is good in the
world....
well... almost all.... which is also nice :)

A question:

I need a macro to check if a document is open, regardless what it's
name
is....

I knwo it sounds weird , but there are cases in wich the word
application
is
open - but there isn't a document open.... I need to check if there is
an
open document - without checking it's name...

Have any Idea?


:

Don't change a thing Iris. I think it's just gorgeous, and your
message
still gets across - which is more that I can say about *some* of the
posts
I've seen.
--
Cheers!

Gordon Bentley-Mix
Word MVP

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


Oooooooohhhhhh.... I gess I wrote this wrong havn't I Gordon...:)

But... If it maid you lough.... It's the least I can do....

I must work on my English.... a second after I'll finish this
thing....

Cheers to you to...



:

Doug,

" I will ... fill you up tomorrow."

Who's a lucky boy then? ;-P
--
Cheers!

Gordon Bentley-Mix
Word MVP

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


:

Thank you so much Doug!

I will try it and fill you up tomorrow.
It is now 2:30 (17/2) am and I am working on this since 06:00
(16/2)...

I hardli open my eyes....

Good night and trully trully thank you for your wilingness to
help!!!

Talk to you tomorrow... :)


:

Hi Doug,

Thank you very much for your answer! :) I appriciate this
very
much
!!

To populate combobox will be the best and easiest thing to do.
But
I
need to
find a word inside the sentence: for example: with a senctence
like
"I am
living in New York City"

In a combobox there is no problem if you search from the first
word:
"I
am...." and so on...

My problem is that I want to search inside the sentence: for
example - the
word "living" - and I want to see all the resaults of this
search -
their
could be 20 or more resaults - that is why I need to populate a
listbox with
the resaults...

thank you again for your answer.... I hope you will be able to
help
me with
that...

and sorry again for the multiple postings... my mistake...


:

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

In that form I have :
textbox1 - in which i write the string I need to search
optionbutton1 - in which I choose the column I need to search
the
string in
the database
comandbutton1 - to execute the search
listbox1 - in which I need the list of the results to appear

The code I wrote execute the search sucssessfully but I
don't
know
how to
build the array for all the resualts.... I only get one
resault
at
a time and
eventually - only the last resault appears in the list box.

I need all the resualts to appear in the listbox.

can someone please help me write the code correctly...?

This is the code I wrote:

Private Sub CommandButton1_Click()

Dim dbDatabase As Database
Dim rse As Recordset
Dim rsi 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 myActiveRecord As Recordset
Dim x As Long
x = 0


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 category", vbOKOnly +
vbExclamation
d = True
Else
If OptionButton1.Value = True Then

ListBox1.Clear

With rse
Do Until .EOF
eStr = ![heb]
If InStr(![heb], TextBox1.Text) > 0 Then
d = True
i = i + 1
TextBox2.Text = ![heb]
ListBox1.AddItem


Set dbDatabase = OpenDatabase("C:\nihul.mdb")

Set myActiveRecord = myDataBase.OpenRecordset("SELECT * FROM
expressions
WHERE heb = '" & TextBox2.Text & "'", dbOpenForwardOnly)

ListBox1.ColumnCount = myActiveRecord.Fields.Count

Do While Not myActiveRecord.EOF
ListBox1.AddItem
ListBox1.ColumnCount = 7
ListBox1.BoundColumn = 7
ListBox1.ColumnWidths = "4 in;1 in;1 in;1 in;1 in;1
in;0
in;"
ListBox1.List(x, 6) = myActiveRecord.Fields("hebrt")
ListBox1.List(x, 5) = myActiveRecord.Fields("heb")
ListBox1.List(x, 4) = myActiveRecord.Fields("engRT")
ListBox1.List(x, 3) = myActiveRecord.Fields("eng")
ListBox1.List(x, 2) =
myActiveRecord.Fields("employeeName")
ListBox1.List(x, 1) = myActiveRecord.Fields("lastUpdate")
ListBox1.List(x, 0) = myActiveRecord.Fields("hebshort")
x = x + x

myActiveRecord.MoveNext
Loop

myActiveRecord.Close
myDataBase.Close
Set myActiveRecord = Nothing
Set myDataBase = Nothing

answer = MsgBox("R U sure?" &
TextBox1.Text
&
". ,
vbQuestion)
If answer = vbNo Then
Exit Sub
Else
End If
End If
.MoveNext
e = e + 1
Loop
 

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

Similar Threads


Top