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

null row records in access displays in ListView

I trying to display all records of table in listview.

But it generates a error if one of the fields does not have a value(null).my codes is below:

Expand|Select|Wrap|Line Numbers
  1.  
  2.  With FrmTithes.ListView.ListItems
  3.             Set TItem = .Add(, , Trs!ID)
  4.  
  5.                TItem.SubItems(1) = Trs!Fullname
  6.                TItem.SubItems(2)= Trs!Jun_2_2013
  7.                TItem.SubItems(2)= Trs!Jun_9_2013
  8.               TItem.SubItems(2)= Trs!Jun_16_2013
  9.  
  10.  
When i run the program the message box appear and says" invalid use of null". I need to display all the records in table even some fields are null! What codes fits best?

Thank you in advance!
Feb 9 '13 #1

✓ answered by Rabbit

An example would be:
Expand|Select|Wrap|Line Numbers
  1. If IsNull(someValue) Then
  2.    'Value is null, do something
  3. Else
  4.    'Value is not null, do something else
  5. End If

9 4209
Rabbit
12,516 Expert Mod 8TB
Convert nulls to a different value, such as a blank string, using the Nz() function.
Feb 10 '13 #2
how can I convert it. can you give me some example codes? I try to search to the internet later but I hope your answer! thanks a lot
Feb 10 '13 #3
Rabbit
12,516 Expert Mod 8TB
A search shows plenty of examples.

Here is a link to Microsoft's documentation on the Nz function.
https://office.microsoft.com/en-us/a...001228890.aspx
Feb 10 '13 #4
I try to visit the link and read about the tutorial I get some Ideas, but i dont know on how to code this. I dont understand well. Forgive me if I'm slow in sql.

The code I do is:

Expand|Select|Wrap|Line Numbers
  1.  
  2.  With FrmTithes.ListView.ListItems
  3.             Set TItem = .Add(, , Trs!ID.null.Value.ToString)
  4.  
  5.                TItem.SubItems(1) = Trs!Fullname
  6.                TItem.SubItems(2)= Trs!Jun_2_2013
  7.                TItem.SubItems(2)= Trs!Jun_9_2013
  8.               TItem.SubItems(2)= Trs!Jun_16_2013
  9.  
  10.  
Its not work and gain errors. What can I do!
I try to search to the internet but there code is very different on me so I cannot understand them well. Please provide some examples and I will study it.
Thanks again!
Feb 11 '13 #5
Rabbit
12,516 Expert Mod 8TB
Sorry, I didn't notice this was for VB6 and not VBA, VB6 does not have the Nz function. You will have to use the IsNull function. Here is a link to the documentation on that function http://www.chennaiiq.com/developers/...ons/isnull.asp.

What you attempted above won't work because that is VB.Net code, not VB6.
Feb 11 '13 #6
It's okay. Rabbit how can I apply it to vb6 I don;t know on how to start code!
Feb 11 '13 #7
Rabbit
12,516 Expert Mod 8TB
An example would be:
Expand|Select|Wrap|Line Numbers
  1. If IsNull(someValue) Then
  2.    'Value is null, do something
  3. Else
  4.    'Value is not null, do something else
  5. End If
Feb 11 '13 #8
Thank you so much for this code it's completely solved my error linking in vb6.
Feb 18 '13 #9
Killer42
8,435 Expert 8TB
Sorry to jump in late here, but for future reference one might also use:
  • IIF function, if it's available (you may have to add a reference to your project, but I no longer have VB6 available to check). Example...
    Expand|Select|Wrap|Line Numbers
    1. TItem.SubItems(1) = IIF(IsNull(Trs!Fullname),"",Trs!Fullname)
  • Concatenation can change your value to a string. Example...
    Expand|Select|Wrap|Line Numbers
    1. TItem.SubItems(1) = "" & Trs!Fullname
Feb 19 '13 #10

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

Similar topics

2
by: ExDelphi | last post by:
Hi All I am fairly new to VB.Net, and have gotten stuck with an invoicing application. My database (Access 2000 / 2003) is used to store records of our products, customers, suppliers etc. The user...
1
by: allyn44 | last post by:
Hello--i have inherited a dataset that has records like below: id locationid 1 7 2 3 5 4 5 6 4
1
by: Mark Richards | last post by:
Hi. I am basically a novice with access. Sorry for the long question, but I can't find a short way to make this clear.... I have a database I created to track service calls for a client with a...
6
by: MS | last post by:
Access 97 here. I want a simple way to "lock" certain records on a form. Some records remain "live" until all data is available which happens over time. When all the fields are complete, I want...
1
by: civa | last post by:
Hii, I have created a check writing program which consists of a table name "DATA" with fields CHECKNO, CHECKDT, BANKNAME & AMOUNT & also a query with date criteria with the above fields. I have 2...
2
by: ILCSP | last post by:
Hello, I'm in the process of changing our 'normal' Access 2000 update queries to Update Pass Through Queries. We have a SQL server 2000 database and we're using an Access 2000 database as our...
2
by: VSS | last post by:
Hello, I need to know what is the maximum number of records Access can hold? I need approx. 6 million records, do you know if Access can hold this amount? Thank you everyone.
2
lee123
by: lee123 | last post by:
I Have A Form (frmLoan) With Loan Details And I Have Made Another Form(frmLoanSummary) In the frmLoanSummary I have Placed A Listview On It. How Can I get the information off of the (frmLoan) To...
2
by: Resmy Ravi | last post by:
how to make a field null in access
2
by: dowlingm815 | last post by:
I have a basic query to extract records not equal to form type "Standing Order." However, it doesn't extract the null record(s). I would appreciate any insight? The following is the input data ...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
0
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...
0
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...

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.