作用于空记录集 [英] acting on null recordset
问题描述
hiya,
除了以下
之外,还发现了我需要的所有内容:
我想生成一些代码允许我在
组合中输入一个字符串,然后根据表格中的字段进行检查。然后,我想要一个消息框,告诉我是否有匹配或
没有。简单!我不知道我是否会绕着房子走,但是
以后几乎可以工作:
Dim db作为数据库
Dim rs As DAO.Recordset
Dim strsql As String
Dim Ref as Integer
strsql =" select * from [first] where [codey] =(''"&
Forms![Form4]!Combo10.Column(1)&"'')"
设置db = CurrentDb()
设置rs = db.OpenRecordset(strsql)
如果不是(IsNull(rs.Fields( 狡猾)))然后
MsgBox没有
否则
MsgBox是
结束如果
我没有收到任何错误但我每次都得到相同的答案
无论我是否有比赛
在此先感谢
Chriso
>如果不是(IsNull(rs.Fields(codey)))那么
**将此行替换为:
如果不是rs.Recordcount然后
-
Bruce M. Thompson,Microsoft Access MVP
bt ****** @ mvps.org (请参阅访问常见问题解答 http://www.mvps.org/access )没有电子邮件请。在新闻组中保留所有通信
,以便所有人都可以受益。<<
c。******** @ blueyonder.co.uk (crisox)在留言新闻中写道: < 31 ************************** @ posting.google。 com> ...hiya,
除了下面的
之外,我发现了我需要的所有内容:
我想制作一些允许我的代码在
组合中输入一个字符串,然后根据表格中的字段进行检查。然后我想要一个消息框,告诉我是否有比赛或
不是。简单!我不知道我是否会绕着房子走,但是接下来的工作非常接近:
Dim db As Database
Dim rs As DAO.Recordset
Dim strsql As String
Dim Ref as Integer
strsql =" select * from [first] where [codey] =(''"&
Forms![Form4] !Combo10.Column(1)&"'')"
设置db = CurrentDb()
设置rs = db.OpenRecordset(strsql)
> If Not(IsNull(rs.Fields(codey)))然后
MsgBox没有
其他
MsgBox" ;是"
结束如果
我没有得到任何错误,但我每次都得到相同的答案
无论我是否有匹配
先谢谢
Chriso
而不是:
如果不是(IsNull .. 。)
尝试
如果不是rs.BOF = rs.EOF
在comp.databases中于2004年2月11日星期三19:11:19 -0500 .ms-access,Bruce
M. Thompson < bthmpson@big_NOSPAM_foot.com>写道:
如果不是(IsNull(rs.Fields(" codey")))那么
> **将此行替换为:
如果不是rs.Recordcount那么
小心使用非布尔值的按位运算符,结果
可能不如预期。
-
A)bort,R)etry,I)用大锤子影响。
hiya,
Found just about everything I need on this group apart from the
following:
I want to produce some code that allows me to enter a string in a
combo which will then be checked against a field in a table. I then
want a message box to appear telling me whether there is a match or
not. Simple! I dont know whether I''m going round the houses but the
following very nearly works:
Dim db As Database
Dim rs As DAO.Recordset
Dim strsql As String
Dim Ref As Integer
strsql = "select * from [first] where [codey] = ( '' " &
Forms![Form4]!Combo10.Column(1) & " '') "
Set db = CurrentDb()
Set rs = db.OpenRecordset(strsql)
If Not (IsNull(rs.Fields("codey"))) Then
MsgBox "no"
Else
MsgBox "yes"
End If
I dont get any errors but I do get the same answer everytime
regardless of whether I have a match or not
Thanks in Advance
Chriso
> If Not (IsNull(rs.Fields("codey"))) Then
**Replace this line with:
If Not rs.Recordcount Then
--
Bruce M. Thompson, Microsoft Access MVP
bt******@mvps.org (See the Access FAQ at http://www.mvps.org/access)NO Email Please. Keep all communications
within the newsgroups so that all might benefit.<<
c.********@blueyonder.co.uk (crisox) wrote in message news:<31**************************@posting.google. com>...hiya,
Found just about everything I need on this group apart from the
following:
I want to produce some code that allows me to enter a string in a
combo which will then be checked against a field in a table. I then
want a message box to appear telling me whether there is a match or
not. Simple! I dont know whether I''m going round the houses but the
following very nearly works:
Dim db As Database
Dim rs As DAO.Recordset
Dim strsql As String
Dim Ref As Integer
strsql = "select * from [first] where [codey] = ( '' " &
Forms![Form4]!Combo10.Column(1) & " '') "
Set db = CurrentDb()
Set rs = db.OpenRecordset(strsql)
If Not (IsNull(rs.Fields("codey"))) Then
MsgBox "no"
Else
MsgBox "yes"
End If
I dont get any errors but I do get the same answer everytime
regardless of whether I have a match or not
Thanks in Advance
Chriso
Instead of:
If Not (IsNull...)
Try
if not rs.BOF=rs.EOF
On Wed, 11 Feb 2004 19:11:19 -0500 in comp.databases.ms-access, "Bruce
M. Thompson" <bthmpson@big_NOSPAM_foot.com> wrote:
If Not (IsNull(rs.Fields("codey"))) Then
**Replace this line with:
If Not rs.Recordcount Then
Be careful using bitwise operators on non boolean values, the result
may not be as expected.
--
A)bort, R)etry, I)nfluence with large hammer.
这篇关于作用于空记录集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!