473,320 Members | 1,926 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,320 software developers and data experts.

How to Detect Null Value in Two Dimensional Array

subedimite
I have a two dimensional Array that is read from a recordset with the GetRows command. I wanted to know if the field in the Array is empty in column 1 and the 75th Record. When I debug print the field it returns Null but it seems like I can not check if the field in Null because the it is not going through the IF statement and the message box does not pop up.

Expand|Select|Wrap|Line Numbers
  1.  NoOfRecords = qryTestFailureRes.RecordCount 'Find out no of failures
  2.     ArrayRecordsTestFailures = qryTestFailureRes.GetRows(NoOfRecords) 
  3.  
  4.         Debug.Print ArrayRecordsTestFailures(1, 75)
  5.         If ArrayRecordsTestFailures(1, 75) = Null Then
  6.             MsgBox "No Description exists in the database: Continue?"
  7.                 TestDescription = "Empty"
  8.             Else
  9.                 TestDescription = ArrayRecordsTestFailures(FieldNum + 1, RecNum + i) 'Test Description
  10.         End If
  11.  
Sep 6 '10 #1
5 5245
TheSmileyCoder
2,322 Expert Mod 2GB
And your problem is?
Sep 6 '10 #2
TheSmileyCoder
2,322 Expert Mod 2GB
I am a bit fuzzy on the comparing to null aspect, and whether there might be some oddities there.

Another approach however could be:
Expand|Select|Wrap|Line Numbers
  1. If IsNull(ArrayRecordsTestFailures(1, 75)) Then
or
Expand|Select|Wrap|Line Numbers
  1. Ff ArrayRecordsTestFailures(1, 75) & ""="" Then
Sep 6 '10 #3
NeoPa
32,556 Expert Mod 16PB
This is one of those rare occasions where merging a duplicate thread makes some sense.

Please be warned for future reference that posting duplicate threads is not allowed and may lead to disciplinary measures.
Sep 6 '10 #4
NeoPa
32,556 Expert Mod 16PB
If the array is Dimmed as Variant (remarkably you don't include that one piece of useful information) then you can use the IsNull() function as Smiley has indicated.
Sep 6 '10 #5
ADezii
8,834 Expert 8TB
I cannot understand why you would want to use a 2-Dimensional Array in this case, buy I'm sure that you must have your reasons. I created for you a Function that will do the job.
  1. Pass to the Function a Valid Data Source in the Form of a Table Name, Query Name, or SQL Statement, as indicated below:
    Expand|Select|Wrap|Line Numbers
    1. Call fFindNullsInArray("qryEmployees")
  2. Change the Value of the Constant conCOLUMN_NUM within the Function to indicate which Column you will check for Nulls. In this case it will be 0 (Column 1).
  3. The Function will create the 2-Dimensional Array, and check the Value in the first Column, every Record, for any Nulls.
  4. If any Nulls are found, Output will be directed to the Immediate Window.
    Expand|Select|Wrap|Line Numbers
    1. Public Function fFindNullsInArray(strDataSource)
    2. Dim MyDB As DAO.Database
    3. Dim rst As DAO.Recordset
    4. Dim varRet As Variant
    5. Dim intRowNum As Integer
    6. Const conCOLUMN_NUM As Byte = 0     '1st Column, Indexed at 0
    7.  
    8. Set MyDB = CurrentDb
    9. Set rst = MyDB.OpenRecordset(strDataSource, dbOpenSnapshot)
    10.  
    11. If rst.BOF And rst.EOF Then Exit Function      '0 Records
    12.  
    13. rst.MoveLast: rst.MoveFirst     'Need a Valid Record Count
    14.  
    15. 'Let's retrieve ALL Rows in the Data Source
    16. varRet = rst.GetRows(rst.RecordCount)
    17.  
    18. For intRowNum = 0 To UBound(varRet, 2)        'Loop thru each Row
    19.   'Analyze each Row - Column 1 only
    20.   If IsNull(varRet(conCOLUMN_NUM, intRowNum)) Then
    21.     Debug.Print "NULL Value in Column: " & (conCOLUMN_NUM + 1) & " | Row: " & (intRowNum + 1)
    22.   End If
    23. Next
    24.  
    25. rst.Close
    26. Set rst = Nothing
    27. End Function
  5. Sample Output based on Test Data:
    Expand|Select|Wrap|Line Numbers
    1. NULL Value in Column: 1 | Row: 8
    2. NULL Value in Column: 1 | Row: 9
P.S. - For the sake of brevity and simplicity, I have omitted Error Checking in the Function Routine. You, on the other hand, should definitely incorporate it into the overall Logic.
Sep 6 '10 #6

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

Similar topics

4
by: Venkat | last post by:
Hi All, I need to copy strings from a single dimensional array to a double dimensional array. Here is my program. #include <stdio.h> #include <stdlib.h>
2
by: ip4ram | last post by:
I used to work with C and have a set of libraries which allocate multi-dimensional arrays(2 and 3) with single malloc call. data_type **myarray =...
16
by: rguti | last post by:
Hi, How do I create a two dimensional array? I have created a one dimensional doing this: Dim laFields As ArrayList = New ArrayList How about to do a 2 dimensional?
4
by: entitledX | last post by:
Hi, I'm trying to use the HDF library to read a few HDF files that I need to process. The data in each file varies in rows, but the columns remain constant. Because of that, I had dynamically...
6
by: Chuck Anderson | last post by:
My knowledge of JavaScript is limited. I learn from example and then adapt those examples to suit my needs. I have stumped myself on this one. I have a form with checkboxes that I want to...
6
by: fniles | last post by:
I need to store information in a 2 dimensional array. I understand ArrayList only works for a single dimensional array, is that correct ? So, I use the 2 dimensional array like in VB6. I pass the...
8
by: per9000 | last post by:
Hi all, I have a two-dimensional array of data, f.x int's. We can imagine that the array is "really large". Now I want the data in it and store this in a one-dimensional array. The obvious...
1
by: streamkid | last post by:
Hello... i have a two dimensional array of ints, int board; when i try to set each element, like that board = { blcaslte, blhorse, blbishop, blking, blqueen, blbishop, blhorse, blcastle,...
272
by: Peter Olcott | last post by:
http://groups.google.com/group/comp.lang.c++/msg/a9092f0f6c9bf13a I think that the operator() member function does not work correctly, does anyone else know how to make a template for making two...
31
by: mdh | last post by:
I am still having a problem understanding K&RII on p 112. I have looked at the FAQs --which I am sure answer it in a way that I have missed, so here goes. A 2-dim array, (per K&R) is really a...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.