473,750 Members | 2,265 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to check for empty string?

11 New Member
Hi,
I am very new to access. I am asking something basic.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command12_Click()
  2.     Dim strAbc As String
  3.     strAbc = "a"
  4.     MsgBox IsNull(strAbc)
  5.     MsgBox IsEmpty(strAbc)
  6. End Sub
How to check if variable strAbc has a value/is not an empty string? I tried isNull and isEmpty and both returns false whether strAbc is assigned "" or "a".

Thanks,
Robin
Aug 16 '10 #1
3 88339
MikeTheBike
639 Recognized Expert Contributor
Hi

You could try this

MsgBox strAbc <> ""

??

MTB
Aug 17 '10 #2
munkee
374 Contributor
I use the following to check for null and zero length string of a control. Just replace control for your string variable.

Expand|Select|Wrap|Line Numbers
  1. Len(Nz(Me.controlname, "")) = 0
or you can just use the straight
Expand|Select|Wrap|Line Numbers
  1. len(string) < 1
Aug 17 '10 #3
NeoPa
32,571 Recognized Expert Moderator MVP
Robin, It's important to know what you are dealing with when making such a check. As yours clearly states it is a string variable, then the correct way to check it would be as Mike has suggested - (strABC = "").

On the other hand, form controls are objects that may contain Null. Checking form controls should be done using IsNull() instead - (IsNull(Me.txtA BC)). Controls with no data entered are never empty strings. Nz() may be used for simplifying usage of the control's value, but is not a good way to test if anything has been entered.
Aug 17 '10 #4

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

Similar topics

6
3511
by: Chris Connett | last post by:
I have an interesting problem with eval(). ---Background Info--- The program I'm working on launches a separate process with a popen to do some highly specialized processing of input, then this process leaves resultant data structured in files, in python syntax, at a known absolute path, which is then read in, eval()'ed, and processed further. It works fine when there are no errors in processing by this external program, but when there...
5
2452
by: VMI | last post by:
How can I validate a null string or an empty string in the same IF statement? If I use this: if (myString.Trim().Length <= 0 || myString == null) { //do stuff } I'll get a run-time error because I can't trim (or get the length) of a Null
11
4606
by: Dan Bass | last post by:
which one do you use and why? MyString == null || MyString == "" vs MyString == null || MyString.Length == 0
21
5757
by: M D | last post by:
You know how you assume you know until you find out you don't know. Well, I typed into a function definition "..., new String("")). I know what I want. Everyone reading this knows what I want. However, the 1.0 compiler has no idea what I want. Can anyone share with me the syntax that will actually communicate the concept to the compiler, please?
3
1819
by: Adam Knight | last post by:
Very basic question!! How do i check for an empty string in vb.net? Ie: If(e.Item.DataItem.Item(3) ?) Then End If
5
5229
by: Tan | last post by:
I am using ObjectDataSource bind to DetailView which will contain one of the column with the value type is date. whenver the value of this column is empty . then it will be display the date in the format ( 01/01/0001), How can I convert it to empty string or just string? Thank you very much tan
2
16308
by: shapper | last post by:
Hello, I need to check if a string is empty. Should I use: String.IsNullOrEmpty(MyString) or MyString Is Nothing? What is the difference?
7
63126
by: tomlebold | last post by:
Are the following two validation the same: 1) IsNull(Me.ColumnName) and Me.ColumnName = "" 2) Me.ColumnName """ It would seem to be better to use: Me.ColumnName """
7
53921
by: lphang | last post by:
I am reading a simple text file that will contains three set of string values as follow: "1234567", "ABC123456", "" I have my codes as follow trying to check for an empty string, with the input string as above, I can never get it to display "testid is empty", Any idea why the test failed?: FileData = open(filename, "r") Filecontents = FileData.readline().strip() FileData.close()
4
3035
by: Jay | last post by:
For a column that contains a string (let's say varchar), is there any performance advantage in not allowing nulls, and using an empty string ("") to instead?
0
9000
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8838
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9339
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8260
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6804
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4713
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4887
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3322
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2225
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.