Multiselect listbox (1 Viewer)

mohammadagul

PrinceAtif
Local time
Today, 22:02
Joined
Mar 14, 2004
Messages
298
how can i use a multiselect listbox to pass criteria for a report. most of the threads i have searched had given the following .

http://www.mvps.org/access/forms/frm0007.htm

but to be honest i do not know how to use it. please help

thanks
 

mohammadagul

PrinceAtif
Local time
Today, 22:02
Joined
Mar 14, 2004
Messages
298
All the Access Gurus Out There Please Give me a Little Clue. Anything To Work With, I really need to have this before tomorow
 

mohammadagul

PrinceAtif
Local time
Today, 22:02
Joined
Mar 14, 2004
Messages
298
why is taht wheni try to download anything from this website the download file shows number instead of the file. after i download it , it doesnot open in access either.. is there somthing wrong with my registration
 

Hayley Baxter

Registered User.
Local time
Today, 19:02
Joined
Dec 11, 2001
Messages
1,607
I can email the sample to you if you are having problems downloading, which version of access are you using?
 

mohammadagul

PrinceAtif
Local time
Today, 22:02
Joined
Mar 14, 2004
Messages
298
Guys and Gurus ...

Please help

i was due to solve this problem today... but failled and due to which i had a really bad day with my boss.... please somone. Check this site and tell me how to use this code. i have trying to downlooad the attachments given in the replies but it does not open

http://www.mvps.org/access/forms/frm0007.htm

someone please help me in this case
 

mohammadagul

PrinceAtif
Local time
Today, 22:02
Joined
Mar 14, 2004
Messages
298
guys i am really disappointed... ther eis no one here to help me in thsi respect
 

Mile-O

Back once again...
Local time
Today, 19:02
Joined
Dec 10, 2002
Messages
11,316
I typed multiselect into the search function and this was returned.

Why didn't you try this? ;)
 

sha7jpm

Registered User.
Local time
Today, 19:02
Joined
Aug 16, 2002
Messages
205
new code

this code has always worked for me... (am certain it came from some kind soul on this msgboard about a yr ago!)



Private Sub Command20_Click()
On Error GoTo Err_Command20_Click

Dim Q As QueryDef
Dim db As Database
Dim Criteria As String
Dim ctl As Control
Dim Itm As Variant
Dim stDocName As String

' Build a list of the selections.
Set ctl = Me![LeaList]

For Each Itm In ctl.ItemsSelected
If Len(Criteria) = 0 Then
Criteria = Chr(34) & ctl.ItemData(Itm) & Chr(34)
Else
Criteria = Criteria & "," & Chr(34) & ctl.ItemData(Itm) _
& Chr(34)
End If
Next Itm

If Len(Criteria) = 0 Then
Itm = MsgBox("You must select one or more items in the" & _
" list box!", 0, "No Selection Made")
Exit Sub
End If

' Modify the Query.
Set db = CurrentDb()
Set Q = db.QueryDefs("individual LEA Green Form Report")

Q.sql = "SELECT [new final table].ProjectsCode, [new final table].[Project description], [new final table].[Date of Stage 4 Completed] FROM [new final table]WHERE [new final table].[Instruments & Quantity] In(" & Criteria & ");"
Q.Close

' Run the report from the listbox fed query
stDocName = "individual LEA Green Form Report"
DoCmd.OpenReport stDocName, acPreview

Exit_Command20_Click:
Exit Sub

Err_Command20_Click:
MsgBox Err.Description
Resume Exit_Command20_Click

End Sub
lea list is the listbox, and you will have the edit the Q.sql....

hth

ps . no idea how the get the code in nice quotes / formatting / sorry!

John
 

Vaimpir

JAFO
Local time
Today, 13:02
Joined
Mar 5, 2004
Messages
78
I have read different posts regarding queries from Multiselect list boxes. I have been able to make them work but what if I am trying to create a report and I need information from the list box as well as one or more tables in my DB. What do i do then?

Steven
 

Mile-O

Back once again...
Local time
Today, 19:02
Joined
Dec 10, 2002
Messages
11,316
The report will reference a query. So build a quey based on the details selected in the listbox.
 

Users who are viewing this thread

Top Bottom