Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to test for zero length string or Null string 1

Status
Not open for further replies.

gcrutch70

Programmer
Oct 21, 2009
11
US
I have some code that uses a table called "Carts" from an Address database. and some of the addresses have units (like Unit A, Unit B, etc) and some doesn't. I need to be able to tell it to go ahead and select it if it doesn't have a unit. I am selecting the address from a list box. And when i choose one that does not have a unit it gives me the error "Field 'Carts.Unit' cannot be a zero-length string". Any help is greatly appreciated!
here is my code:
Private Sub lstAddress_DblClick(Cancel As Integer)

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "New Service"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Forms![New Service].NUMBER.Value = Me.lstAddress.Column(0)
Forms![New Service].UNIT.Value = Me.lstAddress.Column(1)
Forms![New Service].STREETNAME.Value = Me.lstAddress.Column(2)
Forms![New Service].SUFFIX.Value = Me.lstAddress.Column(3)
Forms![New Service].QUADRANT.Value = Me.lstAddress.Column(4)
Forms![New Service].GBRoute.Value = Me.lstAddress.Column(5)

DoCmd.Close acForm, Me.Name, acSaveNo


End Sub
 
How are ya gcrutch70 . . .

... and this:
Code:
[blue]Forms![New Service].UNIT.Value = IIf(Me.lstAddress.Column(1) & "" = "", Null, Me.lstAddress.Column(1))[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
I'm good how are you......I don't know what i would do without Forums like this!

Well that fixed my problem!!!!!!

now i have one other problem. Once the user selects a value and double clicks it. the form closes. I need the list box to be clear again when the user repeats the steps. As it is now, the same list appears from last the value the user chose. In other words, how do i clear the list box once the user is finished. and what event will i put the code in?
 
gcrutch70 . . .

Well ... how are you changing the [blue]RowSource[/blue] of the listbox?

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 

[blue]?[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top