Looking for blank fields

Riaang

Board Regular
Joined
Aug 29, 2002
Messages
146
Hi all,

How can I change the following code so that it looks for all entries that are blank. eg in this code the Reason__letter_not_Posted = n/a. I want to change it to blanks or empty

Private Sub Reason__Letter_Not_Posted__Exit(Cancel As Integer)
If Letter_Posted = "No" And Reason__Letter_Not_Posted_ = "N/A" Then
MsgBox "Please supply a valid reason for not posting this letter."
Me.Letter_Posted.SetFocus
End If
End Sub

Thanks a lot
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Riaang said:
Hi all,

How can I change the following code so that it looks for all entries that are blank. eg in this code the Reason__letter_not_Posted = n/a. I want to change it to blanks or empty

Private Sub Reason__Letter_Not_Posted__Exit(Cancel As Integer)
If Letter_Posted = "No" And Reason__Letter_Not_Posted_ = "N/A" Then
MsgBox "Please supply a valid reason for not posting this letter."
Me.Letter_Posted.SetFocus
End If
End Sub

Thanks a lot

Hi,

Try this:-

If Letter_Posted = "No" And Len(Reason__Letter_Not_Posted_)=0 Then
.....
 
Upvote 0
Thanks for the reply but this only works when there is a 0 in the field. It still doesn't work when the field is empty.

Regards
 
Upvote 0
My apologies (y) I didn't test it. This seems to work OK:-

If Letter_Posted = "No" And (IsEmpty(Reason_Letter_Not_Posted_) Or Len(Reason__Letter_Not_Posted_) = 0) Then
 
Upvote 0
Hi,

This is my code. I copied watever you gave me and it still does not work. Maybe I'm overlooking something

Private Sub Reason__Letter_Not_Posted__Exit(Cancel As Integer)
If Letter_Posted = "No" And (IsEmpty(Reason__Letter_Not_Posted_) Or Len(Reason__Letter_Not_Posted_) = 0) Then
MsgBox "Please supply a valid reason for not posting this letter."
Me.Letter_Posted.SetFocus
End If
End Sub

Thanks for your help.
 
Upvote 0

Forum statistics

Threads
1,221,543
Messages
6,160,421
Members
451,644
Latest member
hglymph

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top