473,839 Members | 1,421 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

acting on null recordset

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.OpenRecordse t(strsql)

If Not (IsNull(rs.Fiel ds("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
Nov 12 '05 #1
31 3409
> If Not (IsNull(rs.Fiel ds("codey"))) Then

**Replace this line with:

If Not rs.Recordcount Then

--
Bruce M. Thompson, Microsoft Access MVP
bt******@mvps.o rg (See the Access FAQ at http://www.mvps.org/access)
NO Email Please. Keep all communications

within the newsgroups so that all might benefit.<<
Nov 12 '05 #2
c.********@blue yonder.co.uk (crisox) wrote in message news:<31******* *************** ****@posting.go ogle.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.OpenRecordse t(strsql)

If Not (IsNull(rs.Fiel ds("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
Nov 12 '05 #3
On Wed, 11 Feb 2004 19:11:19 -0500 in comp.databases. ms-access, "Bruce
M. Thompson" <bthmpson@big_N OSPAM_foot.com> wrote:
If Not (IsNull(rs.Fiel ds("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.
Nov 12 '05 #4
Thanks for your input but I am still getting the same results
everytime - is there something in the preceeding code that is causing
me grief?

Cheers
Chriso
Nov 12 '05 #5
c.********@blue yonder.co.uk (crisox) wrote in
news:31******** *************** ***@posting.goo gle.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.OpenRecordse t(strsql)

If Not (IsNull(rs.Fiel ds("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 rs.BOF Then
--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #6
pi********@hotm ail.com (Pieter Linden) wrote in
news:bf******** *************** ***@posting.goo gle.com:
c.********@blue yonder.co.uk (crisox) wrote in message
news:<31******* *************** ****@posting.go ogle.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.OpenRecordse t(strsql)

If Not (IsNull(rs.Fiel ds("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


Can you think of a situation where this statement:
rs.BOF=rs.EOF
is False for a newly opened RecordSet?

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #7
Thanks for the responses - I have tried them but am still getting the
same response every time - any suggestions?

Cheers
Chriso
Nov 12 '05 #8
>> If Not rs.Recordcount Then

Trevor Best wrote:
Be careful using bitwise operators on non boolean values, the result
may not be as expected.


Nor does it document itself optimally.

I'd do
if rs.recordcount= 0 then
--
Bas Cost Budde
http://www.heuveltop.org/BasCB
but the domain is nl

Nov 12 '05 #9
crisox wrote:
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:


I think you *are* going around the houses.

if dcount("*","[first]","codey='" & combo10.column( 1) &"'")>0 then
msgbox "Yes"
else
msgbox "No"
end if

will do. If the code is in form4, that is, otherwise have the complete
reference.

Do you really mean to get the value in the *second* column of the
combobox, by the way?
--
Bas Cost Budde
http://www.heuveltop.org/BasCB
but the domain is nl

Nov 12 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
15469
by: pam | last post by:
sorry for my poor english first. $notation=$rs->fields; if(!empty($notation)) echo $notation; the notation field in database is a text type, when the value is null, it will cause a mistake; i used empty function to check it, but it seems don't take effect.
5
2951
by: Roger Withnell | last post by:
I'm updating a record by opening a recordset, setting the fields and the updating it with objRS.Update. I need to set an image datatype to NULL. objRS("field") = NULL works for datatypes int and varchar but not for datatype image, although there is no error - the image field still contains the image! I'm using SQL server and running an UPDATE statement including image = NULL works.
14
11130
by: wk6pack | last post by:
Hi, I'm getting this error on my asp page intermittently. One day it is fine, another day, it crashes a lot. I have searched the web and microsoft on this and they say it is a recordset assigned to a session variable. I dont assign any record sets to session variables in my code. I assign values to the session variables though. The place it seems to crash is Set AccessConn = Server.CreateObject("ADODB.Connection")
0
2201
by: Brad | last post by:
Hi all, I've never come across this one before and am hoping someone may be able to shed some light on a very strange situation. I'm using a DNS less connection and a ADO recordset to retrieve records from a networked database. The connection and query all works fine, but the particular field I'm interested in suddenly becomes NULL after a couple of seconds or after I've referenced it once. I've got some test code below which produces...
6
4482
by: Modest Marsupial | last post by:
What is the DAO method of allowing a recordset to have null values? Thanks, marie
4
2807
by: Tony WONG | last post by:
i use the below formula to add up records which is extracted from SQL by ASP. sumQS = cint(objRS1("Q1S")) + cint(objRS1("Q2S")) + .... but if cint(objRS1("Q1S")) is null, it gets error. i read solution from book that add ZERO value to those NULL variables by using IsNULL. is it the only way to deal with this cos i have lots of these variables?
5
62172
nitindel
by: nitindel | last post by:
Hi All, I am working on ASP VBScript... How can i check the values of a recordset .i.e whether it contains values or not...?? Is NULL considered as a string....?? Actually i want to check on a precondion that if recodset is empty ...i want to take some action if not empty then some other action..
3
3550
by: janetopps | last post by:
I have a news website, with asp pages, which was on Access, and i upgraded to MySQL, i used Bullzip to transfer the data. It had about 1000 pages, which im now able to pull up on the public side. Im sorting out a few glitches though. Since i upgraded from ms access database to MySQL, i have added about 4 articles to test the new setup. I note some fields aren't being added in the new mySql database for the new 4 records. When i ran the MySQK...
3
4592
by: phill86 | last post by:
Hi, i have a recordset in a function that is called on the afterupdate event in a form Basically the recordset finds the relevant session records and adds up how long, in hours, the sessions took and wites the sum of the session times into a seperate table this all works fine when i add a record, more time is added and when i delete a record time is taken away but when i delete the last record the error message "invalid use of null"...
0
9856
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9698
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10910
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10589
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9426
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7833
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7021
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5683
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4493
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.