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

Error Trap Zero or Null Values

Hi, I'm trying to write code that will not allow users to continue
unless a Product Sale is entered. This is what I have so far:

Private Sub ForecastProductSale_BeforeUpdate(Cancel As Integer)
If Nz(JobEstimatedProductSale, "") = "" Then
MsgBox "Warning: A Product Sale must be entered.", vbOKOnly,
"Warning"
Exit Sub
End If

End Sub

Can someone please tell me what I'm doing wrong?

Thanks.

Jan 11 '07 #1
4 1511
I did answer the 'almost' same question yesterday ...
But you had code like If IsNull(Me.ForecastProductSale) Then

You need "Cancel=True' instead of "Exit sub"

Arno
<er************@gmail.comschreef in bericht news:11**********************@i39g2000hsf.googlegr oups.com...
Hi, I'm trying to write code that will not allow users to continue
unless a Product Sale is entered. This is what I have so far:

Private Sub ForecastProductSale_BeforeUpdate(Cancel As Integer)
If Nz(JobEstimatedProductSale, "") = "" Then
MsgBox "Warning: A Product Sale must be entered.", vbOKOnly,
"Warning"
Exit Sub
End If

End Sub

Can someone please tell me what I'm doing wrong?

Thanks.
Jan 11 '07 #2
Your code does not trap zero. Try the following, assuming
JobEstimatedProductSale is numeric.

If Nz(JobEstimatedProductSale, 0) = 0 Then

"Arno R" <ar***********@tiscali.nlwrote in message
news:45**********************@text.nova.planet.nl. ..
I did answer the 'almost' same question yesterday ...
But you had code like If IsNull(Me.ForecastProductSale) Then

You need "Cancel=True' instead of "Exit sub"

Arno
<er************@gmail.comschreef in bericht
news:11**********************@i39g2000hsf.googlegr oups.com...
Hi, I'm trying to write code that will not allow users to continue
unless a Product Sale is entered. This is what I have so far:

Private Sub ForecastProductSale_BeforeUpdate(Cancel As Integer)
If Nz(JobEstimatedProductSale, "") = "" Then
MsgBox "Warning: A Product Sale must be entered.", vbOKOnly,
"Warning"
Exit Sub
End If

End Sub

Can someone please tell me what I'm doing wrong?

Thanks.

Jan 11 '07 #3
"paii, Ron" <pa**@packairinc.comschreef in bericht news:gZ******************************@athenet.net. ..
Your code does not trap zero. Try the following, assuming
JobEstimatedProductSale is numeric.

If Nz(JobEstimatedProductSale, 0) = 0 Then

Then what??
The OP was asking for code that will not allow users to continue...

Arno R
Jan 11 '07 #4

"Arno R" <ar***********@tiscali.nlwrote in message
news:45***********************@text.nova.planet.nl ...
"paii, Ron" <pa**@packairinc.comschreef in bericht
news:gZ******************************@athenet.net. ..
Your code does not trap zero. Try the following, assuming
JobEstimatedProductSale is numeric.

If Nz(JobEstimatedProductSale, 0) = 0 Then

Then what??
The OP was asking for code that will not allow users to continue...

Arno R

You already gave him that.
Jan 11 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Kurt Hill | last post by:
I am looking for a way to pass error information back from a COM+ object that is "better" than incliding a byref argument in every single function... The session object would be ideal, except for...
7
by: Jack | last post by:
Hi, I have posted this problem before. Apprently, the suggestion took care of the problem. However, still I am getting the above error message. I am using a session variable to transfer a value...
1
by: franknavec | last post by:
I have created a database in MS Access 2000. I want to compute for percent defective and in the control source I have this expression: =((/)*100). Its OK if I have the numbers greater than zero....
2
by: Bob Darlington | last post by:
When a user clears a value from a combo box (by pressing the delete key), the following message appears: "You tried to assign the null value to a variable that is not a variant data type". ...
2
by: DazedAndConfused | last post by:
I converted a C# example of using dll crypt32 to VB .NET. The converted example fails when Encypting/Decypting. I found that if instead of defining a variable as and setting the values for...
10
by: pemo | last post by:
As far as I understand it, a trap representation means something like - an uninitialised automatic variable might /implicitly/ hold a bit-pattern that, if read, *might* cause a 'trap' (I'm not...
10
by: Richard Tobin | last post by:
May all-bits-zero be a trap representation for a pointer? What if I calloc() space for a structure containing pointers? -- Richard -- "Consideration shall be given to the need for as many as...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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.