OKay, BUt........................

W

wade polk

I need to compare a text/combo box to determine if the user entered data or not. The text box is [plant ID], the code looks like
If [plant ID]=Null Then
DOSOMETHING

I have tried
If [plant ID]=""
and
If IsNull(Plant ID)

Which is the correct way to do this?

EggHeadCafe - .NET Developer Portal of Choice
http://www.eggheadcafe.com
 
D

Douglas J. Steele

The correct way is

If IsNull(Me!PlantID) Then

However, it's possible that the text box isn't Null, but contains a
zero-length string. To be sure, try:

If Len(Trim(Me!PlantID & vbNullString)) = 0 Then
 
F

fredg

I need to compare a text/combo box to determine if the user entered data or not. The text box is [plant ID], the code looks like
If [plant ID]=Null Then
DOSOMETHING

I have tried
If [plant ID]=""
and
If IsNull(Plant ID)

Which is the correct way to do this?

EggHeadCafe - .NET Developer Portal of Choice
http://www.eggheadcafe.com

Looks like there is a space in the field name, so you must enclose the
name within brackets.

If IsNull([Plant ID])
 
D

Douglas J. Steele

Fred's eyes are better than mine: I missed the space.

If Len(Trim(Me![Plant ID] & vbNullString)) = 0 Then

(or do yourself a HUGE favour, and don't use special characters, which
includes blanks, in your names!)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Douglas J. Steele said:
The correct way is

If IsNull(Me!PlantID) Then

However, it's possible that the text box isn't Null, but contains a
zero-length string. To be sure, try:

If Len(Trim(Me!PlantID & vbNullString)) = 0 Then

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I need to compare a text/combo box to determine if the user entered data
or not. The text box is [plant ID], the code looks like
If [plant ID]=Null Then
DOSOMETHING

I have tried
If [plant ID]=""
and
If IsNull(Plant ID)

Which is the correct way to do this?

EggHeadCafe - .NET Developer Portal of Choice
http://www.eggheadcafe.com
 
D

Don CP

Private Sub Phone_Enter()
If IsNull(Phone) Then
Phone = "111"
Phone.SelStart = 5
End If
End Sub

And it worked great. Basically it was some code to enter the area code of a phone # so I didn't have to type it manually. The reason selstart is 5 is that the phone # is formatted as such:
(111)111-1111

Hope this helps :)

EggHeadCafe - .NET Developer Portal of Choice
http://www.eggheadcafe.com/default.aspx?ref=ng
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top