Home |
Search |
Today's Posts |
#1
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how can I print form check boxes and form text boxes in color? | Microsoft Word Help | |||
AutoText drop down boxes empty | Microsoft Word Help | |||
Form: Leaving Empty Fields Empty | Microsoft Word Help | |||
Embedded objects appear as empty boxes | Microsoft Word Help | |||
how do i set up word to show symbols instead of empty boxes? | New Users |