Me.DESCRIPT.ItemData(0) zero-length error

G

Guest

With Me.DESCRIPT

.RowSource = _
"SELECT DISTINCT DESCRIPT FROM PARTS " & _
"WHERE MFG = " & Chr(34) & Me.MFG & Chr(34) & _
"AND PART_NO = " & Chr(34) & Me.PART_NO & Chr(34)
.Requery

Dim MYVAR2
MYVAR2 = Me.DESCRIPT.ItemData(0)
If IsNull(MYVAR2) = False Then
Me.DESCRIPT.Value = MYVAR2
End If

End With


Sometimes DESCRIPT is empty and I "Error '3315' Field 'BOM.DESCRIPT' cannot
be a zero-length string". So I created the IF ISNULL statement to only
display DESCRIPT.VALUE when there is data. When I set to TRUE I dont get the
error, which is good, but also dont get data. When I set to FALSE I get the
data when available and error when empty.

Thanks!
 
M

Marshall Barton

wb said:
With Me.DESCRIPT

.RowSource = _
"SELECT DISTINCT DESCRIPT FROM PARTS " & _
"WHERE MFG = " & Chr(34) & Me.MFG & Chr(34) & _
"AND PART_NO = " & Chr(34) & Me.PART_NO & Chr(34)
.Requery

Dim MYVAR2
MYVAR2 = Me.DESCRIPT.ItemData(0)
If IsNull(MYVAR2) = False Then
Me.DESCRIPT.Value = MYVAR2
End If

End With


Sometimes DESCRIPT is empty and I "Error '3315' Field 'BOM.DESCRIPT' cannot
be a zero-length string". So I created the IF ISNULL statement to only
display DESCRIPT.VALUE when there is data. When I set to TRUE I dont get the
error, which is good, but also dont get data. When I set to FALSE I get the
data when available and error when empty.


A ZLS is not the same as Null. Try changing to:

If MYVAR2 <> "" Then

Or, if Null were a possibility, you could test for both
conditions by using:

If Nz(MYVAR2, "") <> "" Then
 
G

Guest

Thanks! Works Great!!!

Marshall Barton said:
A ZLS is not the same as Null. Try changing to:

If MYVAR2 <> "" Then

Or, if Null were a possibility, you could test for both
conditions by using:

If Nz(MYVAR2, "") <> "" Then
 

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