473,406 Members | 2,710 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,406 software developers and data experts.

Invalid use of null reported when adding db field to listbox.

Hey
Im new in vb and i have some questions.Im trying to make save command but everytime im trying to save debug window pops up with invalid use of null.This is my code please someone help me

Expand|Select|Wrap|Line Numbers
  1. data1.Recordset.AddNew
  2. Data1.Recordset.Update
  3. Data1.Refresh
  4. List1.Clear
  5. Dim val1 As Database, val2 As Recordset, val3 As Field
  6. Set val1 = OpenDatabase(App.Path & "\KONACNO.mdb")
  7. Set val2 = val1.OpenRecordset("Prava")
  8. Set val3 = val2("Ime i Prezime")
  9. val2.MoveFirst
  10. Do While Not val2.EOF
  11.     val2.MoveNext
  12.     List1.AddItem val3
  13. Loop
May 18 '07 #1
6 2106
Dököll
2,364 Expert 2GB
Hey
Im new in vb and i have some questions.Im trying to make save command but everytime im trying to save debug window pops up with invalid use of null.This is my code please someone help me

Expand|Select|Wrap|Line Numbers
  1.  
  2. data1.Recordset.AddNew
  3.     Data1.Recordset.Update
  4.     Data1.Refresh
  5.     List1.Clear
  6.     Dim val1 As Database, val2 As Recordset, val3 As Field
  7.     Set val1 = OpenDatabase(App.Path & "\KONACNO.mdb")
  8.     Set val2 = val1.OpenRecordset("Prava")
  9.     Set val3 = val2("Ime i Prezime")
  10.     val2.MoveFirst
  11.     Do While Not val2.EOF
  12.     val2.MoveNext
  13.     List1.AddItem val3
  14.     Loop
  15.  
  16.  
Greetings and salutations, Dejjzey!

Count your columns, and your blessings, give this another whirl. You should consider making sure your Access end fields are set to have null values allowed, just a hunch. Also, should (List1.Clear) be added after (List1.AddItem val3)???

Sorry for your troubles...

Dököll
May 19 '07 #2
I have done all that and still its not working.
When "Invalid use of Null" window pops up i press debug and it shows me that
is something wrong with (list1.additem val3)
May 27 '07 #3
Killer42
8,435 Expert 8TB
I have done all that and still its not working.
When "Invalid use of Null" window pops up i press debug and it shows me that
is something wrong with (list1.additem val3)
Sounds as though val3 must contain a null value, then. Try displaying it once you go to debugging mode.
May 28 '07 #4
Please, explane me something more. I dont know what to do :(
May 28 '07 #5
Killer42
8,435 Expert 8TB
Sounds as though val3 must contain a null value, then. Try displaying it once you go to debugging mode.
When you hit the error, go to debug mode and display the value of val3. If you don't know how to do that, you really need to study your documentation, and maybe look up some VB tutorials. The debugging tools built into VB are your best friends in a case like this.
May 28 '07 #6
Killer42
8,435 Expert 8TB
By the way, are you aware that your logic will skip the first record? You say to go to the first record, then until you hit the EOF, skip to the next record and put it in the listbox. So the first one will never be loaded.

In fact, now that I think about it, that may be the source of the error. You are doing MoveNext, then loading the field value, then checking for EOF. So if you're at EOF, won't you get an error (or no value) from loading the field?
May 28 '07 #7

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

Similar topics

1
by: Fran?ois Bourdages | last post by:
Hi is there a way to know if object (view, function, etc) are invalid ? let say a have a table t1 (field col1, col2) and a view v1 (field t1.col1, t1.col2) if I drop t1.col2, the view v1 is not...
1
by: James A | last post by:
A particular item in my listbox is null. The field is of type currency. I'm running Access 2000 - SP3 When I use the Isnull(orderitems.column(12,12)) it does not detect it. Also, if i use...
5
by: William Wisnieski | last post by:
Hello Everyone, I have a query by form with several list boxes. The user selects items from the list boxes and clicks a button that returns results in a datasheet subform. One of the list...
15
by: David | last post by:
Hi, I have built a web application that will be a very high profile application. We had tested it, demonstrated it and shown that it all works. On a dress rehearsal run through, it failed...
6
by: doncee | last post by:
I have a list box that is generated on a form by way of a Parameter Query. Problem is whenever I try to refer to the list box, i.e., to update the underlying table, I am getting a "null" value...
6
by: mrmagoo | last post by:
I'm trying to add an object to a listbox. I'm using a DataReader from a resultset from a stored procedure. It works except when there are NULL in any of the rows. Then I get an error: An...
3
by: rando1000 | last post by:
I'm pulling data from a field on a form, evaluating whether or not it's null, then calculating based on the data in the field. Here's my code for evaluating the field: intAdvanced = IIf(Not...
68
by: DaveJ | last post by:
Recently I was working on a project where I came across an issue where the program cored and reported "free(): invalid pointer". I found a resolution for this, but don't fully understand why the...
10
by: =?Utf-8?B?R3JlZw==?= | last post by:
I have the following three files. 1. Users.aspx is a webpage that uses the <asp:ObjectDataSourcecontrol to populate a simple <asp:ListBoxcontrol. 2. The UserDetails.cs file creates a Namespace...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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.