Re: criteria issue
- From: "Michel Walsh" <vanderghast@VirusAreFunnierThanSpam>
- Date: Tue, 1 May 2007 10:01:15 -0400
ID_1 is a field in the table, or an ALIAS to a computed expression? If it is
an alias to a computed expression, you have to use the computed expression,
not the alias. That is required because it generally happens that the WHERE
clause is evaluated BEFORE the SELECT clause itself, so the aliases do not
exists, yet, when the WHERE clause is evaluated, and keep or reject the
rows.
Vanderghast, Access MVP
"bigwillno2 via AccessMonster.com" <u32748@uwe> wrote in message
news:717be9c51ff7a@xxxxxx
Hey Michel thanks for being patient......
your last post look very promising, only thing that i am getting an error,
it's asking me for the [ID_1] selected......
this is my code, can you see what's wrong with it....
strDelim = "" 'Delimiter appropriate to field type. .
strDoc = "rptProduction"
'Loop through the ItemsSelected in the list box.
If Me.sched.ItemsSelected.Count = 0 Then
Beep
MsgBox "no item selected ", 48
Exit Sub
End If
With Me.sched
For Each varItem In .ItemsSelected
If Not IsNull(varItem) Then
'Build up the filter from the bound column (hidden).
strWhere = strWhere & strDelim & .ItemData(varItem) &
strDelim & ","
'Build up the description from the text in the visible
column.
strModelNum = strModelNum & strDelim & .Column(3, varItem)
&
strDelim & ", "
End If
Next
End With
'Remove trailing comma. Add field name, IN operator, and brackets.
lngLen = Len(strWhere) - 1
If lngLen > 0 Then
strWhere = "[OrderNo] IN (" & Left$(strWhere, lngLen) & ")"
End If
lngLen = Len(strModelNum) - 1
If lngLen > 0 Then
strModelNum = "[ID_1] IN (" & Left$(strModelNum, lngLen) & ")"
End If
'Report will not filter if open, so close it.
If CurrentProject.AllReports(strDoc).IsLoaded Then
DoCmd.close acReport, strDoc
End If
'Omit the last argument for Access 2000 and earlier. See note 4.
DoCmd.OpenReport strDoc, acViewPreview, WhereCondition:=strWhere & "
AND
" & strModelNum
', OpenArgs:=strDescrip
Resp = MsgBox("Print??????", vbYesNo)
If Resp = vbYes Then
DoCmd.PrintOut
Else
DoCmd.OpenReport strDoc, acViewPreview, WhereCondition:=strWhere & "
AND
" & strModelNum
', OpenArgs:=strDescrip
Michel Walsh wrote:
Right now, strWhere should be, when printed
Debug.Print strWhere
something look like:
OrderNo IN( "aaa", "b", "cde")
So, build similar string for other fields, such as string strScheduleDate,
to get, once printed, something like
ScheduleDate IN( #01-01-2001#, #02-02-2002#)
and then,
DoCmd.OpenReport "rptProduction", acViewPreview, _
WhereCondition:=strWhere & " AND " & strScheduleDate,
OpenArgs:=strDescrip
to get two criteria based on a list.
Hoping it may help,
Vanderghast, Access MVP
Hey Michel,[quoted text clipped - 55 lines]
sorry that i didnt explained myself better.
OpenArgs:=strDescrip
Resp = MsgBox("Print??????", vbYesNo)
--
Message posted via http://www.accessmonster.com
.
- Follow-Ups:
- Re: criteria issue
- From: bigwillno2 via AccessMonster.com
- Re: criteria issue
- Prev by Date: RE: How to link tables via the field names themselves, not their c
- Next by Date: Re: Select Query on a subform within a form
- Previous by thread: RE: How to link tables via the field names themselves, not their c
- Next by thread: Re: criteria issue
- Index(es):
Relevant Pages
|
Loading