new line in text box

stevelum

Registered User.
Local time
Today, 05:44
Joined
Aug 10, 2015
Messages
12
im hoping someone can help me and i apologize if i am in the wrong place if so please re-direct me.here is my scenario i have created a database for staff to use who work in a car park there role is to patrol and maintain it at the moment they write everything on paper IE: when they patrol the car park ,when they pick up litter etc.therefore the database will log them in in the morning they will enter there details and then really the database is like a running log.here is my problem i have created a button which i call litterpick when they push it it populates a text box which the text "litter pick commenced at:" and the time is added so every time they litterpick they just have to push the button.The problem is because i have to setfocus on the text box if they push another button which says patrol car park the text patrol car park just overwrites litterpick and does not go on a new line so can anyone tell me how to do this .Using a list box worked but it keeps all the text on every record whereas the textbox only does it for that individuals record for that day.Hope that all made sense.Greatfull for any help
 
what is the code for your button, is it like

me.txtBox = "litter pick commenced at:" & Time() & vbNewLine

then for litter picker button:
me.txtBox = me.txtBox & "litter pick commenced at:" & Time() & vbNewLine

and for patrol car park button:
me.txtBox = me.txtBox & "patrol car park at:" & Time() & vbNewLine
 
Thanks for the quick replies much appreciated no i dont need a new record as eac person logs on each day (there is only 2 of them) they will start a new record thats why i need whatever goes in the text box to stay for that record using a list box just keeps the same stuff there for every record.

here is the code for my buttons
button litterpick
Text158.SetFocus
Text158.Text = "Litterpick completed at" & Time

button patrol
Text158.SetFocus
Text158.Text = "Litterpick completed at" & Time

when button patrol is clicked after litterpick all it does is overwrite the text i think because of the setfocus command i have tried chr(10) and vbClCf etc they dont help
 
arnelgp that worked thanks saved me ages of work

many regards
 
the problem with our solution is that when the textbox get full it will not scroll down, so here's the remedy:

button litterpick
Text158.Text = Text158.Text & "Litterpick completed at" & Time & vbNewLine
Text158.SetFocus
Text158.SelStart=Text158.SelLength
SendKeys "^{END}", True

button patrol
Text158.Text = Text158.Text & "Car patrol completed at" & Time & vbNewLine
Text158.SetFocus
Text158.SelStart=Text158.SelLength
SendKeys "^{END}", True


this will scroll your textbox.
 
Last edited:
Yuck SendKeys; Make sure your textbox has vertical scrolling enabled then try a little Sub at the bottom of your class module

Send your Update to the Sub from whereever you want with

strProgMsg = "Litterpick completed at " & Time
DoEvents
Call UpdateProgress(strProgMsg)

Private Sub UpdateProgress(strProgMsg)
'=======================================================================================================
' UpdateProgress:
DoEvents
With Me.Text158 'txtProgressBox
.SetFocus '//required
.Value = .Value & strProgMsg & vbNewLine
.SelStart = Len(.Value)
End With
Me.Repaint

' Return
'=======================================================================================================
End Sub​

vbNewLine and a Repaint will scroll your textbox

Using Call you won't need to do Gosub/Return, but you get that effect

Cheers!
Goh
 

Users who are viewing this thread

Back
Top Bottom