Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-access > #9516

Re: Report determining the number of lines in a CanGrow TextBox

From DFS <nospam@dfs.com>
Newsgroups comp.databases.ms-access
Subject Re: Report determining the number of lines in a CanGrow TextBox
Date 2014-06-14 09:11 -0400
Organization A noiseless patient Spider
Message-ID <lnhhmt$ud7$2@dont-email.me> (permalink)
References <lnhb5m$5hi$1@speranza.aioe.org>

Show all headers | View raw


On 6/14/2014 7:20 AM, Phil wrote:
> I have a report which among other things prints a person’s email address.
> The field width is limited, so in about 30% of the addresses,the Email
> address needs 2 lines. The TextBox is set to CanGrow and CanShrink and will
> hold about 22 characters. On the OnFormat of the detail, I have a routine
> that checks the length of the Email address against the width of the TextBox,
> and if it is too long, I add a linefeed before the “@” in the email address.
> Works fine except where a person’s email address is of the form
> XXXXX@YYYYYYYY.ZZZZZZZZZZ.Co.UK. Then I only get the XXXXX on the first line
> and the address spills onto the third line. So I need advice on how to
> determine if it will spill over to the third line, then I can insert the
> linefeed before the first “.”


Sounds like you'll need to count the total characters, and find the 
position of the @ and one or two periods.  Then if necessary, insert 
your line feeds at those points.


  'VARS
  Dim email As String
  Dim amp As Byte, p1 As Byte, p2 As Byte

  'TEST CASES
  email = "XXXXX@YYYYYYYY.ZZZZZZZZZZ.Co.UK"
  email = "name@someisp.com"
  email = "phil.name@philsisp.co.uk"

  'FIND POSITIONS OF @ AND FIRST 2 PERIODS
  amp = InStr(email, "@")
  p1 = InStr(email, ".")
  p2 = InStr(p1 + 1, email, ".")

  p2 will be 0 if there's only one period in the email address.

I'll leave the insert line-feed code as an exercise for you.



Or easiest of all: make your report field wide enough so when it grows 
to 2 lines it's able to fully show 100% of the emails in your list.

Back to comp.databases.ms-access | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Report determining the number of lines in a CanGrow TextBox "Phil" <phil@stantonfamily.co.uk> - 2014-06-14 12:20 +0100
  Re: Report determining the number of lines in a CanGrow TextBox DFS <nospam@dfs.com> - 2014-06-14 09:11 -0400
  Re: Report determining the number of lines in a CanGrow TextBox Ulrich Möller <knobbi38@usenet.arcornews.de> - 2014-06-14 17:25 +0200
    Re: Report determining the number of lines in a CanGrow TextBox "Phil" <phil@stantonfamily.co.uk> - 2014-06-16 17:08 +0100
      Re: Report determining the number of lines in a CanGrow TextBox Patrick Finucane <patrickfinucanetx@gmail.com> - 2014-06-16 09:31 -0700
      Re: Report determining the number of lines in a CanGrow TextBox Ulrich Möller <knobbi38@usenet.arcornews.de> - 2014-06-16 21:40 +0200
        Re: Report determining the number of lines in a CanGrow TextBox "Phil" <phil@stantonfamily.co.uk> - 2014-06-16 23:46 +0100
          Re: Report determining the number of lines in a CanGrow TextBox Ulrich Möller <knobbi38@usenet.arcornews.de> - 2014-06-17 14:29 +0200
            Re: Report determining the number of lines in a CanGrow TextBox "Phil" <phil@stantonfamily.co.uk> - 2014-06-17 16:56 +0100
              Re: Report determining the number of lines in a CanGrow TextBox Ulrich Möller <knobbi38@usenet.arcornews.de> - 2014-06-18 10:34 +0200

csiph-web