Pass multiple values to ONE FIELD from Form

ppoindexter

Registered User.
Local time
Today, 10:43
Joined
Dec 28, 2000
Messages
134
i have a form that uses unbound combo boxes to pass values to a query for a report....what i need to add to this is a way to pass multiple values to ONE field in the query

presently i use: combo_grade ....which is populated with a list of grade levels ie first grade, second grade, etc....this value is passed to the query and whatever choice was made is the grade level that the report is based on....but i need to be able to select one or two or five or seven different grade levels and pass those to the query ..i was thinking a list box or check boxes would work..but not sure of the syntax or where to place it in the query....
i have read some postings here that pass multiple values but they appear to be passed to more than one field...i need to pass multiple values to ONE field
thanks
 
hi pat
thank you for responding
i have searched and found several samples .....but none that pass multiple values to a single field for the purpose of opening a report...i found one that was close ...it passes mutliple values to a single field but then runs/opens the query..i need it to do this for a report..
any ideas?

i am getting the report to open using the code below, however, when the report opens the only data it shows are the grade level(s) selected...all other fields are not present....these other fields are totally missing from the query that i based the report on...
any ideas?

i have added a list box and a command button as follows:
fldlevel2id is the field that holds the values that i need to filter the query with
i placed this code in the listbox after update

Private Sub LBox_Grades_AfterUpdate()

Dim varItem As Variant
Dim strTemp As String
Dim strSQL As String
Dim db As DAO.Database
Dim qry As QueryDef

strSQL = "SELECT tbllevel2.fldlevel2id, tbllevel2.fldlevel2 FROM tbllevel2 "

For Each varItem In Me.ActiveControl.ItemsSelected
strTemp = strTemp & "((tbllevel2.fldlevel2id) = " & Me.ActiveControl.ItemData(varItem) & ") Or "
Next

strSQL = strSQL & "WHERE (" & Left(strTemp, Len(strTemp) - 4) & ");"

' On Error Resume Next
Set db = CurrentDb
With db
.QueryDefs.Delete "qry_ISEQ_Grade"
Set qry = .CreateQueryDef("qry_ISEQ_Grade", strSQL)
End With

End Sub




and this code on the command button that opens the report


Private Sub Command146_Click()
On Error GoTo Err_Command146_Click

Dim stDocName As String

Let stDocName = Me![Combo_Report].Column(2)
DoCmd.OpenReport stDocName, acPreview

Exit_Command146_Click:
Exit Sub

Err_Command146_Click:
MsgBox Err.Description
Resume Exit_Command146_Click

End Sub
 
pat
thanks for hanging in here with me
sorry i am a bit thick headed

ok
i found some posts as you suggested and have made the following changes

1. have the list box (LBox_Grades) on the form (popfrm_rpt_ISEQ)
set to simple, no codes

2. have report1 with the rowsource set to query1

3. placed a command button to open the report as follows:

Private Sub PreviewReport_Click()

Dim stWhere As String
Dim stDocName As String

stWhere = [tbllevel2].[fldlevel2id] = " & me.LBox_Grades"

Let stDocName = Me![Combo_Report].Column(2)

DoCmd.OpenReport stDocName, acPreview, , stWhere


End Sub

FYI: tbllevel2.fldlevel2id is the field that i want the report to filter on


... drum role please...i get this message when i click "PreviewReport_Clcik"

"Microsoft cant find the field "l' referred to in your expresssion."

can you give another nudge..
 

Users who are viewing this thread

Back
Top Bottom