473,394 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

IsNull is not working

Apologies. I am not an experience programmer so I suspect this is a very simple problem. I am trying to get a piece of code in VB for Access to recognise a null set but unfortunately the test is returning False for IsNull even though I know no records have been found in the table, eg.

Expand|Select|Wrap|Line Numbers
  1. strFeriados = "SELECT tlkpFeriados.* FROM tlkpFeriados WHERE ((tlkpFeriados.Fecha)=#" & CDate(MyDate)& "#);"                                          
  2.  
  3. If IsNull(strFeriados) = False Then
  4.  
  5.  
In other words, there is no record in tlkpFeriados which matches the value of MyDate that I am passing to the sql string yet IsNull is still returning False.

Is the test affected by the format of the date value passed to the string?

Please could someone advice me?

Many thanks in advance!

SB
Jun 1 '10 #1

✓ answered by vb5prgrmr

Okay, looks like a common mistake you are making...

What you want to do it to test the date and just the date. You do not want to test the string variable because it will always return false as you are doing something like...
Expand|Select|Wrap|Line Numbers
  1. strSQL = "Test " & vbNull & "Line"
  2.  
and thus the string is not empty (IsEmpty) either as it contains a string value...

Now, from the looks of it you are actually wanting to test the results returned from executing your query to see if you have any records, which you can do by testing the recordcount property, the bof, and eof properties...
Expand|Select|Wrap|Line Numbers
  1. if Rs.RecordCount <> 0 And Rs.EOF = False And Rs.BOF = False Then
  2.   'have records
  3. Else
  4.   'No Records
  5. End If
  6.  


Good Luck

3 1580
vb5prgrmr
305 Expert 100+
Okay, looks like a common mistake you are making...

What you want to do it to test the date and just the date. You do not want to test the string variable because it will always return false as you are doing something like...
Expand|Select|Wrap|Line Numbers
  1. strSQL = "Test " & vbNull & "Line"
  2.  
and thus the string is not empty (IsEmpty) either as it contains a string value...

Now, from the looks of it you are actually wanting to test the results returned from executing your query to see if you have any records, which you can do by testing the recordcount property, the bof, and eof properties...
Expand|Select|Wrap|Line Numbers
  1. if Rs.RecordCount <> 0 And Rs.EOF = False And Rs.BOF = False Then
  2.   'have records
  3. Else
  4.   'No Records
  5. End If
  6.  


Good Luck
Jun 2 '10 #2
QVeen72
1,445 Expert 1GB
Hi,

You Need to open the recordset ... and check results of recordset
Jun 2 '10 #3
That works! Many thanks.
Jun 2 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Generic Usenet Account | last post by:
I am going through some legacy code that has an "isNull()" method defined on certain classes. I can see that this can be a good way to eliminate certain types of crashes, by making this the first...
4
by: Markus | last post by:
I receive the foolwoing error in my report : "You entered an expression that has no value" In my report i am summing up the all orders with the control =Sum() This control is called Bonus. I...
12
by: Jim's wife | last post by:
I imported a tab delimted text file and am now trying to select all fields that have a blank field in fieldB. isnull(fieldB) nothing is returned i tried fieldB = "" = " " I trimmed it and...
1
by: Samantha | last post by:
I have this code written: Private Sub Command63_Click() If IsNull(DayOneApp) And DayOne <> "" Then MsgBox "Please Enter Yes or No for Approval 1", vbInformation DayOneApp.SetFocus Else If...
2
by: jess | last post by:
Hi All, I am using the PrtDevMode property of a report open in design view to try and flip the orientation of the report between Portrait and Landscape in a user control box before the report is...
3
by: Jan Nielsen | last post by:
Hi I am working with rowfilters in dataviews. I would like to filter for empty fields (= null value in the database) I found this sentence on msdn: **************** To return only those columns...
4
by: Paul Spratley | last post by:
Hi all Firstly this my first time posting to technical groups - so any mistakes I apologise for in advance. I am trying to count records in several secondary tables for the same run in a...
3
by: chucher | last post by:
I'm trying to put a filter into some forms or filters but the filter donīt work properly. I'm using the format dd-mm-yyyy. The forms and the tables always shows how dates in that format. But...
4
by: Hurricane | last post by:
I have an instead of trigger for update on particular table which adds 3 or so columns and puts the total in a 4th No matter what the input is (as long as there is one NULL) the total is always...
3
by: ljungers | last post by:
Have a couple of conditions going on that I can't seem to get working correctly. Have 1 Form only with 3 text boxes that are used in a query, when a command button is clicked using 'Event...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.