Reply
 
Thread Tools Display Modes
  #1   Report Post  
Mdmax Mdmax is offline
Junior Member
 
Posts: 2
Post tell form not to display data from empty boxes

Hi, I have a user form with ten textboxes for medications, they create up to
ten lines of user response data, on a seperate report document.

The bookmarks on the report list the name of the med, the dosage (in mg),
and times per/day taken. The info from these first 3 boxes print to one line
on the report, and then a vbcr (carriage return) takes the next medicine
info, to the next line on the form.

Problem is, the form always generates 10 lines of data (on the report) even
if the textboxes are blank, since I am using the following code for each of
the 10 listings:

ActiveDocument.Bookmarks("med1").Range.Text = TextBox9.Text
ActiveDocument.Bookmarks("mg1").Range.Text = TextBox10.Text
ActiveDocument.Bookmarks("per1").Range.Text = TextBox11.Text & vbcr
ActiveDocument.Bookmarks("med2").Range.Text = TextBox12.Text
ActiveDocument.Bookmarks("mg2").Range.Text = TextBox13.Text
ActiveDocument.Bookmarks("per2").Range.Text = TextBox14.Text & vbcr
etc, etc, etc, creates data for each line on the form (up to 10)

It's probably simple, but I would like to tell the user form to "stop" listing data (on the report), if the next series of textboxes are blank (empty, or contain no data)?
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default tell form not to display data from empty boxes

You would be more likely to get a response to this question if you posted it
in the vba or userforms forums - when In fact you appear to have posted a
similar question a day or so ago. I didn't answer it then as it appeared to
make no sense. With the revised code sample you have posted, the reason that
you are getting all those empty lines is because of the "vbcr" after every
line, which enters a line feed. Conditionally inserting the texts and vbcr
would be a way forward. eg

With ActiveDocument
If TextBox9.Text "" then
.Bookmarks("med1").Range.Text = TextBox9.Text
.Bookmarks("mg1").Range.Text = TextBox10.Text
.Bookmarks("per1").Range.Text = TextBox11.Text & vbcr
End If
If TextBox12.Text "" then
.Bookmarks("med2").Range.Text = TextBox12.Text
.Bookmarks("mg2").Range.Text = TextBox13.Text
.Bookmarks("per2").Range.Text = TextBox14.Text & vbcr
End If
etc
End With

but if all those bookmarks are at fixed locations, it may not do the trick.
--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Mdmax wrote:
Hi, I have a user form with ten textboxes for medications, they create
up to
ten lines of user response data, on a seperate report document.

The bookmarks on the report list the name of the med, the dosage (in
mg),
and times per/day taken. The info from these first 3 boxes print to
one line
on the report, and then a vbcr (carriage return) takes the next
medicine
info, to the next line on the form.

Problem is, the form always generates 10 lines of data (on the report)
even
if the textboxes are blank, since I am using the following code for
each of
the 10 listings:

ActiveDocument.Bookmarks("med1").Range.Text = TextBox9.Text
ActiveDocument.Bookmarks("mg1").Range.Text = TextBox10.Text
ActiveDocument.Bookmarks("per1").Range.Text = TextBox11.Text & vbcr
ActiveDocument.Bookmarks("med2").Range.Text = TextBox12.Text
ActiveDocument.Bookmarks("mg2").Range.Text = TextBox13.Text
ActiveDocument.Bookmarks("per2").Range.Text = TextBox14.Text & vbcr
etc, etc, etc, creates data for each line on the form (up to 10)

It's probably simple, but I would like to tell the user form to "stop"
listing data (on the report), if the next series of textboxes are
blank (empty, or contain no data)?



  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Mdmax-clulessnoob Mdmax-clulessnoob is offline
external usenet poster
 
Posts: 7
Default tell form not to display data from empty boxes

It worked perfectly (of course), I know my etiquette is not very refined, and
I hope that I don't ever wear out my welcome with the professionals, I really
have learned alot with this project. Again, many thanks for your advice!

"Graham Mayor" wrote:

You would be more likely to get a response to this question if you posted it
in the vba or userforms forums - when In fact you appear to have posted a
similar question a day or so ago. I didn't answer it then as it appeared to
make no sense. With the revised code sample you have posted, the reason that
you are getting all those empty lines is because of the "vbcr" after every
line, which enters a line feed. Conditionally inserting the texts and vbcr
would be a way forward. eg

With ActiveDocument
If TextBox9.Text "" then
.Bookmarks("med1").Range.Text = TextBox9.Text
.Bookmarks("mg1").Range.Text = TextBox10.Text
.Bookmarks("per1").Range.Text = TextBox11.Text & vbcr
End If
If TextBox12.Text "" then
.Bookmarks("med2").Range.Text = TextBox12.Text
.Bookmarks("mg2").Range.Text = TextBox13.Text
.Bookmarks("per2").Range.Text = TextBox14.Text & vbcr
End If
etc
End With

but if all those bookmarks are at fixed locations, it may not do the trick.
--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Mdmax wrote:
Hi, I have a user form with ten textboxes for medications, they create
up to
ten lines of user response data, on a seperate report document.

The bookmarks on the report list the name of the med, the dosage (in
mg),
and times per/day taken. The info from these first 3 boxes print to
one line
on the report, and then a vbcr (carriage return) takes the next
medicine
info, to the next line on the form.

Problem is, the form always generates 10 lines of data (on the report)
even
if the textboxes are blank, since I am using the following code for
each of
the 10 listings:

ActiveDocument.Bookmarks("med1").Range.Text = TextBox9.Text
ActiveDocument.Bookmarks("mg1").Range.Text = TextBox10.Text
ActiveDocument.Bookmarks("per1").Range.Text = TextBox11.Text & vbcr
ActiveDocument.Bookmarks("med2").Range.Text = TextBox12.Text
ActiveDocument.Bookmarks("mg2").Range.Text = TextBox13.Text
ActiveDocument.Bookmarks("per2").Range.Text = TextBox14.Text & vbcr
etc, etc, etc, creates data for each line on the form (up to 10)

It's probably simple, but I would like to tell the user form to "stop"
listing data (on the report), if the next series of textboxes are
blank (empty, or contain no data)?




  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default tell form not to display data from empty boxes

You are welcome

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Mdmax-clulessnoob wrote:
It worked perfectly (of course), I know my etiquette is not very
refined, and I hope that I don't ever wear out my welcome with the
professionals, I really have learned alot with this project. Again,
many thanks for your advice!

"Graham Mayor" wrote:

You would be more likely to get a response to this question if you
posted it in the vba or userforms forums - when In fact you appear
to have posted a similar question a day or so ago. I didn't answer
it then as it appeared to make no sense. With the revised code
sample you have posted, the reason that you are getting all those
empty lines is because of the "vbcr" after every line, which enters
a line feed. Conditionally inserting the texts and vbcr would be a
way forward. eg

With ActiveDocument
If TextBox9.Text "" then
.Bookmarks("med1").Range.Text = TextBox9.Text
.Bookmarks("mg1").Range.Text = TextBox10.Text
.Bookmarks("per1").Range.Text = TextBox11.Text & vbcr
End If
If TextBox12.Text "" then
.Bookmarks("med2").Range.Text = TextBox12.Text
.Bookmarks("mg2").Range.Text = TextBox13.Text
.Bookmarks("per2").Range.Text = TextBox14.Text & vbcr
End If
etc
End With

but if all those bookmarks are at fixed locations, it may not do the
trick. --

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Mdmax wrote:
Hi, I have a user form with ten textboxes for medications, they
create up to
ten lines of user response data, on a seperate report document.

The bookmarks on the report list the name of the med, the dosage (in
mg),
and times per/day taken. The info from these first 3 boxes print to
one line
on the report, and then a vbcr (carriage return) takes the next
medicine
info, to the next line on the form.

Problem is, the form always generates 10 lines of data (on the
report) even
if the textboxes are blank, since I am using the following code for
each of
the 10 listings:

ActiveDocument.Bookmarks("med1").Range.Text = TextBox9.Text
ActiveDocument.Bookmarks("mg1").Range.Text = TextBox10.Text
ActiveDocument.Bookmarks("per1").Range.Text = TextBox11.Text & vbcr
ActiveDocument.Bookmarks("med2").Range.Text = TextBox12.Text
ActiveDocument.Bookmarks("mg2").Range.Text = TextBox13.Text
ActiveDocument.Bookmarks("per2").Range.Text = TextBox14.Text & vbcr
etc, etc, etc, creates data for each line on the form (up to 10)

It's probably simple, but I would like to tell the user form to
"stop" listing data (on the report), if the next series of
textboxes are blank (empty, or contain no data)?



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how can I print form check boxes and form text boxes in color? kflynn Microsoft Word Help 0 November 18th 08 04:17 PM
AutoText drop down boxes empty Ernie Microsoft Word Help 1 November 9th 08 10:47 AM
Form: Leaving Empty Fields Empty Rosiewednesday Microsoft Word Help 3 June 11th 08 09:27 AM
Embedded objects appear as empty boxes gmorton119 Microsoft Word Help 0 February 15th 08 04:23 PM
how do i set up word to show symbols instead of empty boxes? granterz New Users 6 May 3rd 05 04:19 AM


All times are GMT +1. The time now is 09:50 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"