过滤RecordSet [英] Filter on RecordSet

查看:50
本文介绍了过滤RecordSet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我似乎无法在我的RecordSet上获得这个过滤器

某些原因。
我有这个代码:


Dim rs As Recordset


设置rs = CurrentDb()。OpenRecordset(" SELECT) DISTINCT产品,

组件,属性,[属性值],[属性类型],[收费

类型]"& _

FROM [Tbl_Product_VAS]"& _

" [Attribute Type]<''Feature''"

& _

ORDER BY [Component]",

dbOpenDynaset)


此记录集与此类记录集不同,例如。

Dim rs As Recordset


设置rs = CurrentDb()。OpenRecordset(" SELECT DISTINCT Product,

Component,Attribute,[Attribute]价值],[属性类型],[收费

类型]"& _

" FROM [Tbl_Product_VAS]"& _

" ORDER BY [组件] ",

dbOpenDynaset)


rs.Filter =" [Attribute Type]<''Feature''"

第一个是得到正确的结果,但第二个是不是。

但是我需要这个功能能够在我继续时过滤掉标准

当我发现越来越多的信息时,我无法继续更新

原始SQL。


有什么想法吗?

谢谢。

Hi,

I dont seem to be able to get this Filter right on my RecordSet for
some reason.

I have this code:

Dim rs As Recordset

Set rs = CurrentDb().OpenRecordset("SELECT DISTINCT Product,
Component, Attribute, [Attribute Value], [Attribute Type], [Charge
Type] " & _
"FROM [Tbl_Product_VAS] " & _
"[Attribute Type] <''Feature'' "
& _
"ORDER BY [Component]",
dbOpenDynaset)

this record set is different to something like this for instance.
Dim rs As Recordset

Set rs = CurrentDb().OpenRecordset("SELECT DISTINCT Product,
Component, Attribute, [Attribute Value], [Attribute Type], [Charge
Type] " & _
"FROM [Tbl_Product_VAS] " & _
"ORDER BY [Component]",
dbOpenDynaset)

rs.Filter = "[Attribute Type] <''Feature''"
The first one is getting the correct results, but the second one isn''t.
but I need the feature to be able to filter out criterias as I go along
when I find out more and more information, and I cannot keep updating
the original SQL.

Any ideas?

Thanks.

推荐答案

2006年10月31日18:32:35 -0800, ja ******** @ gmail.com 写道:
On 31 Oct 2006 18:32:35 -0800, ja********@gmail.com wrote:

>

由于某种原因,我似乎无法在我的RecordSet上获得此过滤器。

我有这样的代码:


Dim rs As Recordset


设置rs = CurrentDb()。OpenRecordset(" SELECT DISTINCT Product,
Component,Attribute,[属性值],[属性类型],[费用
类型]" &安培; _

" FROM [Tbl_Product_VAS]" &安培; _

" [属性类型]<''功能''"
& _

" ORDER BY [Component]",
dbOpenDynaset)


此记录集与此类记录集不同。 br />

Dim rs As Recordset


设置rs = CurrentDb()。OpenRecordset(" SELECT DISTINCT Product,
Component,Attribute, [属性值],[属性类型],[充电
类型]"& _

" FROM [Tbl_Product_VAS]"& _

ORDER BY [Component]",
dbOpenDynaset)


rs.Filter =" [Attribute Type]<''Feature''"

第一个是获得正确的结果,但第二个是不是。
但我需要这个功能能够在我找到时过滤掉标准
出了越来越多的信息,我无法不断更新原来的SQL。

任何想法?

谢谢。
>Hi,

I dont seem to be able to get this Filter right on my RecordSet for
some reason.

I have this code:

Dim rs As Recordset

Set rs = CurrentDb().OpenRecordset("SELECT DISTINCT Product,
Component, Attribute, [Attribute Value], [Attribute Type], [Charge
Type] " & _
"FROM [Tbl_Product_VAS] " & _
"[Attribute Type] <''Feature'' "
& _
"ORDER BY [Component]",
dbOpenDynaset)

this record set is different to something like this for instance.
Dim rs As Recordset

Set rs = CurrentDb().OpenRecordset("SELECT DISTINCT Product,
Component, Attribute, [Attribute Value], [Attribute Type], [Charge
Type] " & _
"FROM [Tbl_Product_VAS] " & _
"ORDER BY [Component]",
dbOpenDynaset)

rs.Filter = "[Attribute Type] <''Feature''"
The first one is getting the correct results, but the second one isn''t.
but I need the feature to be able to filter out criterias as I go along
when I find out more and more information, and I cannot keep updating
the original SQL.

Any ideas?

Thanks.



设置过滤器属性后,需要在

原件上打开另一个记录集才能看到结果。


rs.Filter =" [Attribute Type]<''Feature''"

Set rsNew = rs.OpenRecordset


rsNew将包含过滤后的记录。

rs将保持不变。


Wayne Gillespie

Gosford NSW Australia

Once you have set the filter property, you need to open another recordset on the
original to see the results.

rs.Filter = "[Attribute Type] <''Feature''"
Set rsNew = rs.OpenRecordset

rsNew will contain the filtered records.
rs will remain unchanged.

Wayne Gillespie
Gosford NSW Australia


您是否也可以将SQL与记录集混合搭配?


例如,如果我在Recrodset中获取数据后然后我想

go

SELECT * FROM rcdset WHERE fieldName =" Blah"


Wayne Gillespie写道:
Will you also be able to mix and match SQL with recordset?

like for example if after I get my data in a Recrodset then I want to
go
SELECT * FROM rcdset WHERE fieldName="Blah"


Wayne Gillespie wrote:

2006年10月31日18:32:35 -0800, ja ******** @ gmail.com 写道:
On 31 Oct 2006 18:32:35 -0800, ja********@gmail.com wrote:




我似乎无法得到这个s在我的RecordSet上过滤

某些原因。

我有这个代码:


Dim rs As记录集


设置rs = CurrentDb()。OpenRecordset(" SELECT DISTINCT Product,

Component,Attribute,[Attribute Value],[Attribute Type], [收费

类型]" &安培; _

" FROM [Tbl_Product_VAS]" &安培; _

" [属性类型]<''功能''"

& _

" ORDER BY [Component]",

dbOpenDynaset)


此记录集与此类似例如。

Dim rs As Recordset


设置rs = CurrentDb()。OpenRecordset(" SELECT DISTINCT Product,

组件,属性,[属性值],[属性类型],[收费

类型]"& _

" FROM [Tbl_Product_VAS]"& _

" ORDER BY [Component]",

dbOpenDynaset)


rs.Filter =" [Attribute Type] <''功能''"

第一个是获得正确的结果,但第二个是不是。

但是我需要这个功能当我发现越来越多的信息时,能够过滤出标准

,我无法继续更新

原始版本SQL。


有什么想法吗?


谢谢。
Hi,

I dont seem to be able to get this Filter right on my RecordSet for
some reason.

I have this code:

Dim rs As Recordset

Set rs = CurrentDb().OpenRecordset("SELECT DISTINCT Product,
Component, Attribute, [Attribute Value], [Attribute Type], [Charge
Type] " & _
"FROM [Tbl_Product_VAS] " & _
"[Attribute Type] <''Feature'' "
& _
"ORDER BY [Component]",
dbOpenDynaset)

this record set is different to something like this for instance.
Dim rs As Recordset

Set rs = CurrentDb().OpenRecordset("SELECT DISTINCT Product,
Component, Attribute, [Attribute Value], [Attribute Type], [Charge
Type] " & _
"FROM [Tbl_Product_VAS] " & _
"ORDER BY [Component]",
dbOpenDynaset)

rs.Filter = "[Attribute Type] <''Feature''"
The first one is getting the correct results, but the second one isn''t.
but I need the feature to be able to filter out criterias as I go along
when I find out more and more information, and I cannot keep updating
the original SQL.

Any ideas?

Thanks.



设置过滤器属性后,需要在

原件上打开另一个记录集才能看到结果。


rs.Filter =" [Attribute Type]<''Feature''"

Set rsNew = rs.OpenRecordset


rsNew将包含过滤后的记录。

rs将保持不变。


Wayne Gillespie

Gosford NSW Australia


Once you have set the filter property, you need to open another recordset on the
original to see the results.

rs.Filter = "[Attribute Type] <''Feature''"
Set rsNew = rs.OpenRecordset

rsNew will contain the filtered records.
rs will remain unchanged.

Wayne Gillespie
Gosford NSW Australia


嘿伙伴,


感谢您的回复但

我现在遇到了问题它的说法错误3061:我太少了

参数...期待2

这一行设置rs = rs.OpenRecordset()


我不知道为什么它期望2个参数。

代码如下:

请勿rsRef.EOF

AllAttributeNull = True

ChargeTypeEventOnly = True

rs.FindFirst(" [Component] =''"& rsRef![Component]& &&& ;,


而不是rs.NoMatch

如果rs![Attribute]<" Null"那么

AllAttributeNull = False

结束如果


如果rs![费用类型]<"事件"并且rs![费用类型]<>

" Null"然后

ChargeTypeEventOnly = False

结束如果


rs.FindNext(" [Component] =''"& rsRef![Component]&"''")

Wend


如果AllAttributeNull = True那么


如果ChargeTypeEventOnly = True那么

''如果所有属性都为空且只有收费类型是

事件然后删除整个组件

rs。 filter =" rs![Component]<''" &安培; rsRef![组件]&

"''"

设置rs = rs.OpenRecordset()

否则

''如果所有属性都为null但不仅事件存在

ie。 RC / NRC然后显示所有Null记录

rs.filter =" rs![Component]<''" &安培; rsRef![Component]&

"''OR(rs![Component] =''"& rsRef![Component]&"''AND rs![Charge

类型] =''空'')"

设置rs = rs.OpenRecordset()

结束如果


否则

''如果属性存在则只需删除所有Null

atttributes

rs.filter =" rs ![组件]<''" &安培; rsRef![组件]& "''

OR(rs![Component] =''"& rsRef![Component]&"''AND rs![Attribute]<>

''Null'')"

设置rs = rs.OpenRecordset()

结束如果


rsRef.MoveNext


循环

Hey mate,

Thanks for the response but
I now have the problem of its saying that Error 3061: I have too few
parameters...Expect 2
on this line Set rs = rs.OpenRecordset()

I have no idea why its expecting 2 parameters for.
Code Below:
Do While Not rsRef.EOF
AllAttributeNull = True
ChargeTypeEventOnly = True

rs.FindFirst ("[Component] = ''" & rsRef![Component] & "''")

While Not rs.NoMatch
If rs![Attribute] <"Null" Then
AllAttributeNull = False
End If

If rs![Charge Type] <"Event" And rs![Charge Type] <>
"Null" Then
ChargeTypeEventOnly = False
End If

rs.FindNext ("[Component] = ''" & rsRef![Component] & "''")
Wend

If AllAttributeNull = True Then

If ChargeTypeEventOnly = True Then
''If all attributes are null and only charge type is
event then remove whole component
rs.filter = "rs![Component] <''" & rsRef![Component] &
"''"
Set rs = rs.OpenRecordset()
Else
''If all attributes are null but not only event exists
ie. RC/NRC then display the all Null record
rs.filter = "rs![Component] <''" & rsRef![Component] &
"'' OR (rs![Component] = ''" & rsRef![Component] & "'' AND rs![Charge
Type] = ''Null'')"
Set rs = rs.OpenRecordset()
End If

Else
''If attributes exists then simply remove all the Null
atttributes
rs.filter = "rs![Component] <''" & rsRef![Component] & "''
OR (rs![Component] = ''" & rsRef![Component] & "'' AND rs![Attribute] <>
''Null'')"
Set rs = rs.OpenRecordset()
End If

rsRef.MoveNext

Loop


这篇关于过滤RecordSet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆