Pull through to email if not null (1 Viewer)

Fozi

Registered User.
Local time
Today, 10:01
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!! :eek:

Thanks for any help received and time spent.
 

Fozi

Registered User.
Local time
Today, 10:01
Joined
Feb 28, 2006
Messages
137
Thanks Kafrin

Will give it a go.

cheers
Frank
 

Kafrin

Database Designer
Local time
Today, 10:01
Joined
Feb 17, 2009
Messages
149
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
 

Kafrin

Database Designer
Local time
Today, 10:01
Joined
Feb 17, 2009
Messages
149
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.
 

Fozi

Registered User.
Local time
Today, 10:01
Joined
Feb 28, 2006
Messages
137
Kafrin

That done the trick! Thanks for all your help.

Frank
 

Users who are viewing this thread

Top Bottom