A List Box Question (1 Viewer)

D

DevelComp

Guest
Sorry if this is long - but to understand what i am trying
to do is important.

I have a Simple ListBox based on a table. The table is a
type of maintainance table where the customer adds
additions to the database. There are no index fields in
this table. The Maintainance Table is only used to store
extra information about the properties such as carparking,
acreages ect.

They enter all the information about a particular property
into a property form which pulls the information from the
maintainance table. This form has an index field and is
stored into its own property table.

They than use the search form to provide a detail report
for the customer based on what he/she is after such as
pricerange, acreage ect.

When the Search Form is opened, it deletes the previous
information stored in a Listing Table and than adds all
the Listings to that table so they can search for all the
records. The Search Form I am using is not bound to any
tables. It also has a subform in it which has all the
property listings in it in datasheet view. The subform has
a record source.

I can get it to do everything that i am after including
search for a particular suburb, pricerange ect. Now I want
to put in a simple listbox so i can select multiple
suburbs. The code I have will allow me to send the
information from the simple listbox to the debug window,
but i dont know how to get it to run a delete query that
will only show the selected suburbs.

The following is just a test form that i use until i work
the codes out.

Here is the code for the button to display it in the debug
window:

Private Sub Command2_Click()
Dim frm As Form, ctl As Control
Dim varItm As Variant, intI As Integer

Set frm = Forms!Form2
Set ctl = Me!lstMyListBox
For Each varItm In ctl.ItemsSelected
For intI = 0 To ctl.ColumnCount - 1

Debug.Print ctl.Column(intI, varItm)
Next intI
' Debug.Print
Next varItm
End Sub

Here is the code for a hidden txtfield:
Private Sub lstMyListBox_AfterUpdate()
Dim strCriteria As String
Dim varItem As Variant

strCriteria = ""

'Construct criteria for report.
For Each varItem In Me.lstMyListBox.ItemsSelected
strCriteria = strCriteria & "Suburb='" &
Me.lstMyListBox.ItemData(varItem) & "' OR "
Next varItem

'remove last OR
strCriteria = Left(strCriteria, Len(strCriteria) - 4)

Me.txtInvisible = strCriteria

End Sub

Sorry again for such a long explanation.

I thank you in advance for all your efforts.
Jimmy Muir
Devel-Comp
develco@hotkey.net.au http://209.204.199.61/
 

Users who are viewing this thread

Top Bottom