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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

auto scroll text in textbox horizontally

Status
Not open for further replies.

2sj

MIS
Apr 5, 2005
9
US
Say you have a text box that holds text longer than the actual length of a texbox. space on my form is limited, so i'd like it to autoscroll the text in the box (like winamp autoscrolls the track/artist title), preferrably on mouse over, but i'll take what I can get.<br><br>Any ideas?

Oh and I'd like it to do this while the textbox is locked and uneditable.
 
Here's something I came up with

I put a textbox on the form Text0
another textbox Text3
gave Text0 a value with a very long string and then on the
On Timer Event I placed the following code

Me.Text0.SelStart = Me.Text3
Me.Text3 = Me.Text3 + 1

you can set the Timer Interval for how fast you want it to scroll.
 
clapper62,

I cannot get your solution to work nor see how the OnTimer event code could work.
Code:
Me.Text0.SelStart = Me.Text3
is attempting to assign a string value (i.e. the default Text or Value property) to a numeric property (SelStart). Likewise,
Code:
Me.Text3 = Me.Text3 + 1
tries to add a numeric value to a string value. In fact, both lines trigger a Type Mismatch error.


Regards,
Mike
 
Hi Mike,

I think there is some confusion here between VBA UserForms and Access Forms here - and I don't know which the OP is using.

clapper62's code does (sort of) work but needs a bit of refinement for a serious solution - if, indeed, there is a viable one at all.

I'm not sure I like the idea - I'm not sure it can be done smoothly - I think a Label would be a better control than a locked textbox - and I think a form so busy that it needs this kind of gimmickry is badly designed - that's probably enough of my views [smile]

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
Tony,

Good point. I don't use Access, directly, much so I forget how different it is from other Office programs. I agree with your philisophical comments, as well. 2sj's request sounded like a good challenge, though, so I've been working on something in Excel. To get it to work reasonably well is messy, as expected. I'll probably post my code when it's sufficiently tweaked.


Regards,
Mike
 
I'm using vba with an access front end. I agree with Tony, it's probably not worth the hassle nor the time. Plus, he's right, I doubt too that it would work smoothly enough on the form anyways. But thought it would be interesting enough to atleast post the question. I sitll wouldn't mind seeing if someone could get it to 'work'. thanks for the responses.
 
I agree with Tony, particularly with his comment re: labels.

Textboxes are for INPUT. User input. If the user is not typing something into it, you should not be using a textbox. Use a label.

Gerry
See my Paintings and Sculpture
 
2sj, post thread705-1076010 from the Access VBA forum might work.

From PHV
Code:
Me![textbox name].ControlTipText = Me![textbox name].Value

Doesn't auto scroll but would show the whole text of the field if < than 256 characters.
 
Sorry it didn't work for you 2sj it worked for me
admittedly not a smooth scroll. I agree that the idea
may not be the best form design and I like the tool tip
idea. I'm curious as to why it didn't work for you though.

I did see one problem with my posted code in that Text3 must be initalized to some value and the timer interval
must be set to something other than zero.


As for Mikes reply

Me.Text0.SelStart = Me.Text3
is attempting to assign a string value (i.e. the default Text or Value property) to a numeric property (SelStart).

Sorry as I said I neglected to mention that Text3 must be initialized to an integer.

Likewise,

CODE
Me.Text3 = Me.Text3 + 1
tries to add a numeric value to a string value. In fact, both lines trigger a Type Mismatch error.

likewise Text3 is meant to be an integer value

what exactly happened when you tried it?

I've done scrolling on label captions in the past that looked pretty good but it involved making a label object for each letter that you wanted to see and then cycling the values of the label captions.
 
clapper62,

Tony correctly pointed out that you were probably working in MS Access. As I mentioned, I haven't used Access much so didn't recognize this possibility and the significant differences in the forms compared to, say, Excel, which is what I work with most. Therefore, when I mocked your code up in an Excel Userform, I got the Type Mismatch errors.

I did work up a scrolling texbox in Excel that works reasonably well, but agree with Tony philosophically on the design issues.

Regards,
Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top