使用Recordset中的搜索Critera查找记录 [英] Find Records using Search Critera in Recordset

查看:130
本文介绍了使用Recordset中的搜索Critera查找记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。我想找一些符合我搜索条件的记录。


Dim rsMainTable As Recordset

Const strDBPath =" C:\\\ternalDatabase.mdb"

Dim sql as String


设置dbExternalDatabase = OpenDatabase(strDBPath)

设置rs = dbExternalDatabase .OpenRecordset(sql,dbOpenSnapshot)


我们可以使用的查询:


喜欢* &安培; [输入要搜索的任何字符:]& *


搜索匹配的字符,但这里我可以在记录集中搜索。如果有人能解决我的问题,请告诉我。


如果值匹配,那么我们可以设置如下形式的记录集:


设置Me.Recordset = rs


请指导我如何做到这一点。


感谢你。


问候

/>
Mohammad Faisal

Hi Everybody. I wana look for some records which matches my search criteria.

Dim rsMainTable As Recordset
Const strDBPath = "C:\ExternalDatabase.mdb"
Dim sql as String

Set dbExternalDatabase = OpenDatabase(strDBPath)
Set rs = dbExternalDatabase .OpenRecordset(sql, dbOpenSnapshot)


for queries we can use:

Like "*" & [Enter any character to search by: ] & "*"

to search for the matching characters but here how i can search in recordset. please tell me if somebody have solution to my problem.

and if values matches then we can set recordset of a form like this:

Set Me.Recordset = rs

Please guide me how i can do this.

thanking you.

regards

Mohammad Faisal

推荐答案


大家好。我想找一些符合我搜索条件的记录。


Dim rsMainTable As Recordset

Const strDBPath =" C:\\\ternalDatabase.mdb"

Dim sql as String


设置dbExternalDatabase = OpenDatabase(strDBPath)

设置rs = dbExternalDatabase .OpenRecordset(sql,dbOpenSnapshot)


我们可以使用的查询:


喜欢* &安培; [输入要搜索的任何字符:]& *


搜索匹配的字符,但这里我可以在记录集中搜索。如果有人能解决我的问题,请告诉我。


如果值匹配,那么我们可以设置如下形式的记录集:


设置Me.Recordset = rs


请指导我如何做到这一点。


感谢你。


问候

/>
Mohammad Faisal
Hi Everybody. I wana look for some records which matches my search criteria.

Dim rsMainTable As Recordset
Const strDBPath = "C:\ExternalDatabase.mdb"
Dim sql as String

Set dbExternalDatabase = OpenDatabase(strDBPath)
Set rs = dbExternalDatabase .OpenRecordset(sql, dbOpenSnapshot)


for queries we can use:

Like "*" & [Enter any character to search by: ] & "*"

to search for the matching characters but here how i can search in recordset. please tell me if somebody have solution to my problem.

and if values matches then we can set recordset of a form like this:

Set Me.Recordset = rs

Please guide me how i can do this.

thanking you.

regards

Mohammad Faisal



这应该会有所帮助。


首先,请看3个替代搜索方法的链接其中InStr方法似乎最适合搜索记录集。
http://support.microsoft.com/kb/209536


其次,这是我的代码库中的代码(代码记入JerryKlmns),它显示了如何使用InStr函数循环记录:

This should help.

Firstly, see this link for 3 alternative search methods, of which the InStr method seems to be most suitable for searching a recordset.
http://support.microsoft.com/kb/209536

Secondly, here is code from my code library (the code is credited to JerryKlmns), that shows how to loop a recordsdet using the InStr function:

展开 | 选择 | Wrap | 行号



这应该有所帮助。


首先,请参阅此链接以获取3种替代搜索方法,其中InStr方法似乎最适合搜索记录集。
http://support.microsoft.com/kb/209536


其次,这是我的代码库中的代码(代码记入JerryKlmns),它显示了如何使用InStr函数循环记录:
This should help.

Firstly, see this link for 3 alternative search methods, of which the InStr method seems to be most suitable for searching a recordset.
http://support.microsoft.com/kb/209536

Secondly, here is code from my code library (the code is credited to JerryKlmns), that shows how to loop a recordsdet using the InStr function:
展开 | 选择 | Wrap | 行号



感谢您的代码朋友。但如果你能告诉我如何使用这个功能,我将不胜感激?例如,我有一个带有文本字段和命令按钮的表单。那么我怎么能用这个功能呢?感谢你。等待你的回复。


问候


Mohammad Faisal
thank you for your code friend. but i will be grateful to you if u you kindly tell me how i can use this function? for instance i have a form with a text field and a command button. then how i can use this function? thank u. waiting for ur reply.

regards

Mohammad Faisal



穆罕默德,

我已在下面为您解释过,但如果您打算使用文本框和按钮,我认为您最初提到的通配符方法更好。现在,我不明白为什么你想首先使用记录集..


__________________________________________________ ________

1.功能代码必须被复制/粘贴在标准模块中。

2.你必须用你的应用程序中这些对象的实际名称替换功能代码中使用的通用对象名称(如下面粗体图所示)。


设置rstSearchMe = CurrentDb.OpenRecordset(" YourTableName ",dbOpenSnapshot)

.Fields(" YourPKFieldNameHere " ;)& " |" &安培; _

3.编译代码。


4.您可以使用按钮后面的以下代码来调用函数:

该函数将搜索从您指定的表中创建的记录集中的每个字段作为要搜索的数据源。

Mohammad,
I have explained that for you below, but if you plan to use a textbox and a button, I think the wildcard method you originally mentioned is better. Now, I don''t understand why you want to use a recordset in the first place..

__________________________________________________ ________
1. The function code has to be copied/pasted in a standard module.
2. YOu must replace the generic Object names used in the function code (as shown below in boldface) with the actual name of these objects in your application.

Set rstSearchMe = CurrentDb.OpenRecordset("YourTableName", dbOpenSnapshot)

.Fields("YourPKFieldNameHere") & "|" & _
3. Compile your code.

4. you would use the following code behind your button to call the function:
The function will search every field in the recordset created from the table you designate as the data source to be searched.

展开 | 选择 | Wrap | 行号


这篇关于使用Recordset中的搜索Critera查找记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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