Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Anyone know how to program carriage returns into a text box?

Status
Not open for further replies.

CompAnalyst

Programmer
Nov 11, 2003
33
US
Ok... dumb question. I have a report which needs to have a certain section snapped to the bottom of the last page of the report (and kept together). I have tried a variety of things, but nothing really works. So here is the lastest idea: have an unbound text box above the section which would insert a carriage return until the number of pages goes up one, then it would delete the last carriage return.

I understand loops, what i dont understand is how to tell it to create carriage returns and how to tell it to delete the last carriage return.

As it stands now, i basically have to do this manually, by exporting the report to word, then manually inserting return until the section is at the bottom of the last page, then converting it to a .pdf file. I know this is very cumbersome and just a tad dumb :)

Help would be greatly appreciated.

Rachel, Compensation Analyst
 
The only way I know of is maybe to do something like this:
Code:
Private Sub Combo1_AfterUpdate
  Call txtTextBox1_KeyDown
End Sub

Private Sub txtTextBox1_KeyDown(KeyCode As Integer, Shift As Integer)
  Do While [green]'your criteria here[/green]
    KeyCode = 13
  Loop
  [green]'then code to delete last line..
End Sub

[green]'or using this event:
Private Sub txtTextBox1_KeyPress(KeyAscii As Integer)
  Do While [green]'your criteria here[/green]
    KeyAscii = 13
  Loop
  [green]'then code to delete last line..
End Sub

You may end up being better to do a For Next, after using some code to see how many lines you need.. and not terribly sure where to call the event from. You of course, will also need to make sure it is taking these actions in Word, not in Access.. I've not done any vb code in access yet, but from what I've seen, much of the different methods are transferrable between the different office apps.

Stephen [infinity]
"Jesus saith unto him, I am the way, the truth, and the life:
no man cometh unto the Father, but by me." John 14:6 KJV
 
Have a play with page breaks in the report - you can put them in before and after each section. You could then put your "must have at end of page" section in the page/report footer.

Try playing with that and see where you go. Might be easier then coding something up.

If at first you don't succeed, try for the answer.
 
kjv1611....
Thanks! I am going to do some futzing around with it and see if i can get it to work.. :)


GummowN....
could you please elaborate? I am not sure how i could accomplish that. I have tried messing with the Keep Together property, with no luck. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top