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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IsNull or not IsNull

Status
Not open for further replies.

onemiland

Programmer
May 29, 2004
18
US
I'm stumped!

Code follows:
strBody = strBody & "(W) " & Left$(Work_Phone, 3) & "-" & Mid$(Work_Phone, 4, 3) & "-" & Right$(Work_Phone, 4) & Chr(13)
strBody = strBody & "(C) " & Left$(Cell_Phone, 3) & "-" & Mid$(Cell_Phone, 4, 3) & "-" & Right$(Cell_Phone, 4) & Chr(13) & Chr(13)

strBody = strBody & "Work Address" & Chr(13)
strBody = strBody & WAddress & Chr(13) & WCity & ", " & WState & " " & WZip & Chr(13) & Chr(13)
strBody = strBody & AKO_eMail & Chr(13)

This is producing data from a client onto an e-mail message (sendObject). When there is no Phone Number for Home, work or Cell, the e-mail won't be produced. But it works if there isn't a work address. I tried Nz Function for the phone Numbers but I'm stuck.

I appreciate your help.

-Michael
 
Michael

I suspect the reason the phone fails and the address (sort of) works is because you are parsing the phone.

I am not sure of the exact reasoning behind your code, but perhaps something like...

Code:
Dim strSpaceIt as string * 20
Dim strBody as string

If Len(Nz(Work_Phone),"")>0 Then
   strBody = strBody & "(W) " & Left$(Work_Phone, 3) & "-" & Mid$(Work_Phone, 4, 3) & "-" & Right$(Work_Phone, 4) & Chr(13)
Else
   strBody = strBody & Left(strSpaceIt, 15) & Chr(13)
End If

If Len(Nz(Work_Phone),"")>0 Then
   strBody = strBody = strBody & "(C) " & Left$(Cell_Phone, 3) & "-" & Mid$(Cell_Phone, 4, 3) & "-" & Right$(Cell_Phone, 4) & Chr(13) & Chr(13)

Else
   strBody = strBody & Left(strSpaceIt, 15) & Chr(13) & Chr(13)
End If

strBody = strBody & "Work Address" & Chr(13)

'etc...

This code would "fill" missing info with blank space where I am guessing you have 15 spaces. You can of course choose to use just line feeds (vbCRLF) or ommit missing entries entirely.

Richard
 
Thanks for your input. I'm learning tons of stuff here.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top