473,406 Members | 2,745 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.

Verify if a text box = 0 is has nothing in it?

8
I am trying to verify if a text box is equal to 0 or is blank before the close button is pushed. The code works if the box equals 0 but not if it is blank. Can anyone help me with this. Here is the code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command33_Click()
  2. UnusedHRS.SetFocus
  3. If UnusedHRS = 0 Or UnusedHRS = Null Then
  4.     DoCmd.Close
  5. ElseIf UnusedHRS <> 0 Then
  6.     MsgBox "There are still hours that are unaccounted for", vbInformation, "Staffmark"
  7.     End If
  8. End Sub
Jul 4 '10 #1

✓ answered by Jerry Maiapu

If I can understand you properly then try this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command33_Click()
  2.  If Me.UnusedHRS = 0 Or IsNull(Me.UnusedHRS) = True Then
  3.   DoCmd.Close
  4.    Else
  5.        MsgBox "There are still hours that are unaccounted for", vbInformation, "Staffmark"
  6. Me.UnusedHRS.SetFocus
  7.     End If
  8.  End Sub
  9.  
If still not working replace
Expand|Select|Wrap|Line Numbers
  1. IsNull(Me.UnusedHRS)=True
in line#2 with
Expand|Select|Wrap|Line Numbers
  1. Me.UnusedHRS)=" "
Cheers..Hope this helps. Note: Using "Me" makes the code run faster.

Jerry

4 1985
Jerry Maiapu
259 100+
If I can understand you properly then try this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command33_Click()
  2.  If Me.UnusedHRS = 0 Or IsNull(Me.UnusedHRS) = True Then
  3.   DoCmd.Close
  4.    Else
  5.        MsgBox "There are still hours that are unaccounted for", vbInformation, "Staffmark"
  6. Me.UnusedHRS.SetFocus
  7.     End If
  8.  End Sub
  9.  
If still not working replace
Expand|Select|Wrap|Line Numbers
  1. IsNull(Me.UnusedHRS)=True
in line#2 with
Expand|Select|Wrap|Line Numbers
  1. Me.UnusedHRS)=" "
Cheers..Hope this helps. Note: Using "Me" makes the code run faster.

Jerry
Jul 5 '10 #2
rhuns
8
Thanks Jerry, for the help the IsNull() worked perfectly!
Jul 5 '10 #3
Jerry Maiapu
259 100+
Glad I could help

Regards

JM
Jul 5 '10 #4
NeoPa
32,556 Expert Mod 16PB
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command33_Click()
  2.     UnusedHRS.SetFocus
  3.     If Nz(Me.UnusedHRS, 0) = 0 Then
  4.         DoCmd.Close
  5.     Else
  6.         MsgBox "There are still hours that are unaccounted for", vbInformation, "Staffmark"
  7.     End If
  8. End Sub
I would consider putting this code in the Form_Close() event procedure instead. Otherwise the form could be closed another way and it would work fine, thereby leaving hours unaccounted for.

PS. Using IsNull() is also a perfectly reasonable approach. I prefer Nz(), but that's my personal choice.
Jul 5 '10 #5

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

Similar topics

8
by: gunawardana | last post by:
I have to write a program to verify text field in HTML forms. So,I hane to verify a text field with lenth 10 & maxlenth 10.The entered text should be as follows. xxxxxxxxxy where xxxxxxxxx...
4
by: sweep | last post by:
Hi there, I have a problem with some CSS I'm writing and I was looking for a little help. I have a nav bar at the top and left side of my page in CSS which work fine. The remaining space has a...
5
by: Lenard Gunda | last post by:
hi! I have the following problem. I need to read data from a TXT file our company receives. I would use StreamReader, and process it line by line using ReadLine, however, the following problem...
7
by: trint | last post by:
I have a textbox (textBox7) that isn't updating.. Is there a way, after I type new text in it, to have it update? It seems to be fairly normal: public class Form1 : System.Windows.Forms.Form {...
2
by: Gaz | last post by:
> Hi all > > I am trying to write a program that opens a text file and manipulates the data. > > I have managed to open the text file into a textbox1 as a string > i now wish to add code to a...
4
by: sparks | last post by:
In this database some of the text boxes need to be/show something like 88.9. in the table I marked them single, format 00.0 and decimal places 1 on the form I have fixed and 1 if someone types...
1
by: Grey | last post by:
I have to write a program to verify email address availability. i have to verify thousand of email address. is there any way to verify the email in ..net instead. the requirement is to verify which...
9
by: Jonathan Wood | last post by:
Does anyone know of any reason a button on a master page would have no effect? I have a complex HTML page that I'm converting to ASP.NET, and acknowledge I could have something odd that is...
2
by: =?Utf-8?B?SlA=?= | last post by:
Hi all. I'm having a problem with a postback issue and I think it's cache related. Here's my setup: I have a web site that has a signup section. This has simple things like name, age, birth...
2
by: twindude | last post by:
i want to keep this as simple as possible.... website - all html event.txt (or event.html) trying to figure out how to take a txt file and update a place on a website i would like to not use...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.