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

Invalid Use of Null error?

26
Hi,

I am using Ms Access 2000.

i wrote a simple VBA Code to perform addition operation based on the user input.

I used AfterUpdate event for each fields to update the value to Sub_Total

but when i run the code, the value is not updated in Sub_Total field. instead, the field is totally blank and i inserted MsgBox Sub_Total to check whether addtion works fine, i got an error message "Invalid Use of Null".

the code is large so i just paste a part of it.

Code:

Private Sub FaM_Rate_AfterUpdate()

updateFaM_Cost

End Sub
----------------------------------------------------------------------------------
Private Sub updateFaM_Cost()

FaM_Cost.Value = FaM_Rate.Value * FaM_Sheets.Value
updateSubTotal

End Sub
------------------------------------------------------------------------------------
Private Sub FaM_Sheets_AfterUpdate()

updateFaM_Cost

End Sub
---------------------------------------------------------------------------------------
Private Sub FM_Metres_AfterUpdate()

updateFMCost

End Sub
--------------------------------------------------------------------------------------
Private Sub FM_Rate_AfterUpdate()

updateFMCost

End Sub
-------------------------------------------------------------------------------------
Private Sub updateFMCost()

FM_Cost.Value = FM_Metres.Value * FM_Rate.Value

updateSubTotal

End Sub
-------------------------------------------------------------------------------------
Private Sub updateSubTotal()

Sub_Total.Value = (FM_Cost.Value) + (FaM_Cost.Value)
MsgBox Sub_Total

End Sub



I am getting the value for FM_Cost and FaM_Cost. i am getting an error message in updateSubTotal() as "invalid use of null"

could anyone help me in this regard

thanks
Sep 19 '07 #1
3 1661
FishVal
2,653 Expert 2GB
Hi, Asle.

Empty controls contain Null's.
Every expression either logic or arithmetic with Null operand will return Null.
e.g.
5+Null=Null

If you are expecting empty controls values to be treated as zeroes, then you should use Nz() function.
e.g.
when
FM_Cost.Value = 5
FaM_Cost.Value = Null
Sub_Total.Value = (FM_Cost.Value) + (FaM_Cost.Value) = 5 + Null = Null
Sub_Total.Value = Nz(FM_Cost.Value) + Nz(FaM_Cost.Value) = 5 + 0 = 5

Hope this makes sense.
Sep 19 '07 #2
Asle
26
Hi, Asle.

Empty controls contain Null's.
Every expression either logic or arithmetic with Null operand will return Null.
e.g.
5+Null=Null

If you are expecting empty controls values to be treated as zeroes, then you should use Nz() function.
e.g.
when
FM_Cost.Value = 5
FaM_Cost.Value = Null
Sub_Total.Value = (FM_Cost.Value) + (FaM_Cost.Value) = 5 + Null = Null
Sub_Total.Value = Nz(FM_Cost.Value) + Nz(FaM_Cost.Value) = 5 + 0 = 5

Hope this makes sense.
thanks FishVal

that solves my problem...

thanks a lot for ur help.

chuz...
Sep 19 '07 #3
FishVal
2,653 Expert 2GB
You are welcome.

Best regards,
Fish
Sep 19 '07 #4

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

Similar topics

6
by: Thomas Barth | last post by:
Hi, I'm new to windows programming and still reading a book about windows-programming with C++. I copied the following code from the book into my ide (Eclipse/CDT) to comprehend the code, but two...
4
by: rawheiser | last post by:
Behavior I found: Invalid Column name in select embedded in a IN() clause appears to return a NULL, and fails silently - completing the query giving incorrect results. Behavior I expected: ...
1
by: Patrick Dunnigan | last post by:
Hi, I am attempting a bulk copy from a c program into SQL Server 2000 using DBLib in freeTDS 0.63 RC11 (gcc 3.4.3, RH 9). I am getting an error message that I cannot find any documentation on. ...
7
by: Dica | last post by:
i've used the sample code from msdn to create an encyption/decryption assembly as found here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT10.asp i'm...
0
by: Jerry | last post by:
Below is ALL the code for all the databases... Here's the problem: I callup the aspx file in IE and the form comes up just fine. When I select a person to update, I get the subject error. ...
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...
9
by: Jamie | last post by:
I am receiving an Invalid ViewState error after posting back to the same page twice. Consistently the error occurs after the second postback and not after the first. I have looked into creating...
3
by: some one | last post by:
I have kind of wired problem, I using httpwebrequest to post form data to server , in the GetResponse stage a WebException occurred, after tracing the actual error that occurs on the server, I...
6
by: KWienhold | last post by:
I'm currently working on a project in C# (VS 2003 SP1, .Net 1.1) that utilizes IStream/IStorage COM-Elements. Up to now I have gotten everything to work to my satisfaction, but now I have come...
0
by: shrik | last post by:
I have following error : Total giant files in replay configuration file are : File name : /new_file/prob1.rec Given file /new_file/prob1.rec is successfully verified. Splitting for giant file...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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...

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.