Value of field ""

S

Sash

I have the following:

If Not IsNull(rs.Fields("INS2")) Or rs.Fields("INS2") = "" Then
***rest of program***

I added rs.Fields("INS2") because the field in the recordset is blank, but
was not realizing that in the program. When I tried to debug the program it
was showing this field equal to "". However the aforementioned doesn't work
either. Any suggestions would be greatly appreciated!
 
A

Allen Browne

Is rs at a valid record? Examples where it may not be:
a) there are no records in the recordset, or
b) you used a FindFirst that didn't find a match, or
c) you use a Move that moved above the first or after the last record.

If that's not the issue, ask Access what's going on. Set a breakpoint (F9,
or type STOP on a line in your code.) When it breaks there, open the
Immediate Window (Ctrl+G) and enter:
? rs!INS2

It is unusual for a field to contain a zero-length string, unless you have
assigned that as a default value.
 
D

Douglas J. Steele

Sorry, what are you trying to trap for? Your condition will be true anytime
the field's Not Null, and a zero-length string will be Not Null.

If you want to know when there's actually something in the field, try

If Len(rs.Fields("INS2") & vbNullString) > 0 Then
 
D

DaveT

x is text field (in your case x = rs.fields("INS2")

If Len(Nz(x)) = 0 then
'text field is null or is zero len string ("")
Else
'text field has something in it. It is not null and is not a zero len
string
End If
 

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