访问自动过滤问题 [英] Access Automatic Filtering Problem

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

问题描述




我在标题表单区域有一个带有1个文本框的表单,在详细区域中有连续表单样式的数据。我想做一个自动过滤器。所以当我输入一个字符时,细节区域中的数据将被过滤掉。例如:我在文本框中键入字母A,然后使用以A开头的数据过滤数据,如果我继续输入例如:ABB,那么将使用ABB开始的数据过滤数据,依此类推。

实际上我已经有了这个代码,但是代码有点弱点,代码无法接受空格字符。

下面是代码:


私有子txtCari_Change()

如果修剪(txtCari.Text)=""然后

Me.FilterOn = False

Me.txtCari.SetFocus

Else

Me.Filter ="打包像''' &安培; txtCari.Text& " *''"

Me.FilterOn = True

Me.txtCari.SelStart = 100

结束如果

End Sub


当我输入例如ABB然后按空格按钮时,上面的代码失败。文本框中的字符仅显示没有SPACE字符的ABB。似乎代码会自动删除SPACE字符。


请告知如何解决这个问题


问候,

fbachri

Hi,

I have a form with 1 textbox in the header form area and data in continuous form style in detail area. i would like to make an automatic filter. so when i type a character the data in the detail area would be filtered. for example: i type a letter A in the textbox then the data would be filtered with the data started with an A, and if i continue typing for example : ABB then the data would be filtered with the data started with ABB and so on.
Actually i already have a code for this, but there is a little weakness on the code, the code could not accept a SPACE character.
Below is the code:

Private Sub txtCari_Change()
If Trim(txtCari.Text) = "" Then
Me.FilterOn = False
Me.txtCari.SetFocus
Else
Me.Filter = "Pack Like ''" & txtCari.Text & "*''"
Me.FilterOn = True
Me.txtCari.SelStart = 100
End If
End Sub


the code above fails when i type for example ABB then i press Space button. the character in the textbox only appear ABB without a SPACE character. it seems that the code automatically delete the SPACE character.

Please Advise how to solve this problem

regards,
fbachri

推荐答案

你可以试试这个:


Private Sub txtCari_Change()


如果 Len( Trim(txtCari.Text))= 0 那么

Me.FilterOn = False

Me.txtCari.SetFocus

Else

Me.Filter =" Pack Like''" &安培; txtCari.Text& " *''"

Me.FilterOn = True

Me.txtCari.SelStart = 100

结束如果


结束子


修剪文本后测试长度。如果只输入空格,则长度将为零,它将重置过滤器,否则它将过滤您输入的内容,包括空格。
You could try this:

Private Sub txtCari_Change()

If Len(Trim(txtCari.Text)) = 0 Then
Me.FilterOn = False
Me.txtCari.SetFocus
Else
Me.Filter = "Pack Like ''" & txtCari.Text & "*''"
Me.FilterOn = True
Me.txtCari.SelStart = 100
End If

End Sub

It''ll test the length after you trim the text. If only spaces are entered, the length will be zero and it will reset the filter, otherwise it''ll filter for what you entered, including spaces.



你可以试试这个:


私人子txtCari_Change()


如果 Len( Trim (txtCari.Text))= 0 然后

Me.FilterOn = False

Me.txtCari.SetFocus

否则

Me.Filter =" Pack Like''" &安培; txtCari.Text& " *''"

Me.FilterOn = True

Me.txtCari.SelStart = 100

结束如果


结束子


修剪文本后测试长度。如果只输入空格,则长度将为零,它将重置过滤器,否则它将过滤您输入的内容,包括空格。
You could try this:

Private Sub txtCari_Change()

If Len(Trim(txtCari.Text)) = 0 Then
Me.FilterOn = False
Me.txtCari.SetFocus
Else
Me.Filter = "Pack Like ''" & txtCari.Text & "*''"
Me.FilterOn = True
Me.txtCari.SelStart = 100
End If

End Sub

It''ll test the length after you trim the text. If only spaces are entered, the length will be zero and it will reset the filter, otherwise it''ll filter for what you entered, including spaces.



谢谢Cweiss,


但遗憾的是,当我输入包含空格的字符时,你的代码仍无效。空间角色仍然自动消除。


我已经上传了访问应用程序的示例表单。也许你可以帮忙检查一下。


这个链接:

http://s63.yousendit.com/d.aspx?id=0...O3T0MRJMW8S3XT


提前感谢

问候,

fbachri

Thanks Cweiss,

but unfortunately your code still not work when i type character including space. the space character still automatically eliminated.

well i have upload the sample form of my access application. maybe you can help to check it.

this the link:

http://s63.yousendit.com/d.aspx?id=0...O3T0MRJMW8S3XT

thanks in advance
Regards,
fbachri


.SelStart将起点设置为现有文本的结尾它会回到最后一个角色。

http://msdn.microsoft.com/library/de...1df3adc5aa.asp
.SelStart sets the starting point to the end of the existing text so it kicks back to the last character.

http://msdn.microsoft.com/library/de...1df3adc5aa.asp


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

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