Pull through to email if not null

Fozi

Registered User.
Local time
Today, 22:38
Joined
Feb 28, 2006
Messages
137
Hi folks

In my form there's an email button. This pulls through certain form data to the email combined with generic text.

I have a block of controls on my form which are comments boxes. I need the email to pull through any comments in these boxes unless the box is empty - null or "".

I've tried the following:
Code:
stDocBody = stDocBody & Nz(Me.TandEQ1aC, Me.TandEQ1aC.Visible = False) & vbCrLf
        stDocBody = stDocBody & Nz(Me.TandEQ1bC, Me.TandEQ1bC.Visible = False) & vbCrLf
        stDocBody = stDocBody & Nz(Me.TandEQ2aC, Me.TandEQ2aC.Visible = False) & vbCrLf

As the above no doubt demonstrates I'm not big on VB!! :o

Thanks for any help received and time spent.
 
Thanks Kafrin

Will give it a go.

cheers
Frank
 
Ideally you want to create a loop that will run through the required controls. There are several ways to do this. Here's a possible bit of code...
Code:
Dim CtrlsToUse As Variant, Ctr As Byte
 
CtrlsToUse = Array("1aC", "1bC", "2aC")
stDocBody = ""
 
For Ctr = 0 To CtrlsToUse.UBound -1
 
    If Not IsNull(Me("TandEQ" & CtrlsToUse(Ctr))) Then
        If stDocBody <> "" Then stDocBody = stDocBody & vbCrLf
        stDocBody = stDocBody & Me("TandEQ" & CtrlsToUse(Ctr))
    End If
    
Next Ctr
 
Fozi, sorry if this is now confusing. Had accidently posted before finishing writing the post - bad habit of hitting Tab when writing code to indent it, which doesn't work on forums! So deleted unfinished posts and posted complete code, but obviously not til you'd started writing your reply.

Anyhow, the above code is now the complete version, hope it helps.
 
Kafrin

That done the trick! Thanks for all your help.

Frank
 

Users who are viewing this thread

Back
Top Bottom