Hiding a text box and its label when display of the info is unwanted

Ah! YES!
I forgot to check the print preview (DOH)

This works:
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

  Me.Text35.Visible = (Me.ContactTypeID <> 25)
  Me.Label38.Visible = (Me.ContactTypeID <> 25)
 
End Sub

Many thanks everyone.
 
Yes, sorry, I misread the OP. Use <> . Those parentheses are entirely optional.

Another approach that doesn't require VBA is to use expression in textboxes (will also work in ReportView). Use a textbox as a label.

=IIf([ContactTypeID]=25, Null, [some field name])
=IIf([ContactTypeID]=25, Null, "some text here")

Or an all-in-one textbox:
=IIf([ContactTypeID]=25, Null, "some text here: " & [some field name])

Those expressions can even be in RecordSource SQL and bind textboxes.

Seems I've read reports with VBA behind them peform slower.
 
Last edited:
Yes, sorry, I misread the OP. Use <> . Those parentheses are entirely optional.

Another approach that doesn't require VBA is to use expression in textboxes (will also work in ReportView). Use a textbox as a label.

=IIf([ContactTypeID]=25, Null, [some field name])
=IIf([ContactTypeID]=25, Null, "some text here")

Or an all-in-one textbox:
=IIf([ContactTypeID]=25, Null, "some text here: " & [some field name])

Those expressions can even be in RecordSource SQL and bind textboxes.

Seems I've read reports with VBA behind them peform slower.
Yes, I used IIF() elsewhere to hide a label when a textbox was null:-
=IIf(IsNull([Committee Role]),Null,"Committee Role") (y)

Thanks for the further detail.
In this case, apart from my testing, this is only done once a year in anger, so speed is not much of an issue!
This code I'm using does generate a preview of every email in its own window, which does seem to make Outlook slooooooooow. (c. 90 windows)
It also takes a good while [minutes] to put the emails into the drafts folder.

This is the relevant bit:

Code:
            '   OUTLOOK Sending Bits
            Set OutMail = OutApp.CreateItem(olMailItem)
            On Error Resume Next
            With OutMail
                .To = strEmail
                .Subject = strSubject
                .BodyFormat = olFormatHTML
                .HTMLBody = strMsg
                .ReadReceiptRequested = False
                If strFileNameRenewal <> "" Then .Attachments.Add strFileNameRenewal
                If strFileNameGiftAid <> "" Then .Attachments.Add strFileNameGiftAid
                If strFileNameSTO <> "" Then .Attachments.Add strFileNameSTO
                .Display   'or use .Send to immediately send. As this runs with .Display it will save the emails in your drafts.
            End With

I might investigate options there.
Thanks again,
 
No, they will all be in your outbox, so you can still review them.
Else put a limit on how many are created at any one time.
 
When I use .Send, email is sent immediately, not just sitting in Outbox.
 
I believe it depends on your Send/Receive settings?
Plus there has to come a time you rely on your code?
 

Users who are viewing this thread

Back
Top Bottom