Showing Specific Text When Text Is Longer Than Text Box (1 Viewer)

jo15765

Registered User.
Local time
Yesterday, 18:53
Joined
Jun 24, 2011
Messages
130
I have a text box on a form, with a button. When the button is pressed it opens a File Dialog Browser, and allows the user to select a file to input. I can not make the text box any longer, so as a work around I was wanting to show the furthest right of the text (file name and extension)

I am setting the text box value like this
Code:
txtSelectedFile.Value = .SelectedItems(1)

I want the textbox to show the location and file name, but instead of only showing C:\Test\Folder One\Dir One\ have the text box show Test1.xlsx .... I do not want to show only the file name as I want the user to see the location as well.

Maybe a hover option to show the full location and file name?
 

Micron

AWF VIP
Local time
Yesterday, 21:53
Joined
Oct 20, 2018
Messages
3,478
First thought that comes to mind is the zoom box. You make a small form and with some event (e.g. double click on the path textbox) you pop up the small form with the full path. The zoom box form should open modal and popup and have only an OK or Close button - unless you want to be able to do something else at this point besides just read it. I suppose this is for subsequent users since the user who puts the value there already knows the path since they chose it.

Tool tip text feature can be wonky at times, and the annoying thing about mouseover events is that they fire whether you intended them to or not.

EDIT - alternative to zoom box would be a message box or replicating the Shift+F2 feature, which is an actual zoom box. However, that allows you to edit the value if the form control is editable - not sure what happens if the form control is locked. (turns out I can edit the zoom contents but cannot save the change to the control).
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 21:53
Joined
May 21, 2018
Messages
8,525
This may be of interest
 

jo15765

Registered User.
Local time
Yesterday, 18:53
Joined
Jun 24, 2011
Messages
130
I didn't think about a mouse-over event...hmmmm....I wonder if I can set that to show the file name only and leave the value of the text box equal to full path :D.
 

Micron

AWF VIP
Local time
Yesterday, 21:53
Joined
Oct 20, 2018
Messages
3,478
I have a love-hate relationship with mouseover event. You drag your mouse from point A to point B and accidentally touch an object with the event and it fires, interrupting your work, so I love to hate them. I think I would use a double click or something else, but you could end up with the same result either way.
 

isladogs

MVP / VIP
Local time
Today, 02:53
Joined
Jan 14, 2017
Messages
18,209
Using a mousemove event to show a label caption works well as it doesn't interrupt the user.
However I agree with Micron if using that to show a message box.
My preference in this situation is still a customised zoom box form.
 

Isaac

Lifelong Learner
Local time
Yesterday, 18:53
Joined
Mar 14, 2017
Messages
8,774
Maybe a hover option to show the full location and file name?
You answered your own question on this one. On Mouse Move event procedure to make the textbox's ControlTipText property value equal to the textbox value.

However, keep in mind there are limits to the length of controltiptext, too..
 

jo15765

Registered User.
Local time
Yesterday, 18:53
Joined
Jun 24, 2011
Messages
130
How do I get to the Mouse Over Event? When I go to design view, and look at the property sheet and look at events I do not see a mouse over event.
 

Isaac

Lifelong Learner
Local time
Yesterday, 18:53
Joined
Mar 14, 2017
Messages
8,774
I may have misspoken .. air code - MouseMove event?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 02:53
Joined
Feb 19, 2013
Messages
16,607
so as a work around I was wanting to show the furthest right of the text
simple solution perhaps - right justify the control?
 

Isaac

Lifelong Learner
Local time
Yesterday, 18:53
Joined
Mar 14, 2017
Messages
8,774
Yet another option is to look into the SelText property of the textbox...I'm not sure if it scrolls text along with selecting, or not, but you could play with it and find out.
 

jo15765

Registered User.
Local time
Yesterday, 18:53
Joined
Jun 24, 2011
Messages
130
I didn't even know that was an option. Thanks for the option
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 09:53
Joined
May 7, 2009
Messages
19,231
it is better to save the path+filename to anther variable and use the textbox (txtSelectedFile) as display only:

txtSelectedFile.Value = FileDot(.SelectedItems(1), 25)
'the actual value saved to another textbox (visible = False)
'use the value on this textbox instead.
[txtHidden] = .SelectedItems(1)

add this function in a Module:
Code:
' arnelgp
'add "..." between the path and filename
Public Function FileDot(ByVal sPath As String, ByVal iWidth As Integer) As String

Dim sFileName As String
If Len(sPath) <= iWidth Then
    FileDot = sPath
    Exit Function
End If

sFileName = Mid(sPath, InStrRev(sPath, "\") + 1)
sPath = Replace(sPath, sFileName, "")
sFileName = "..." & sFileName
FileDot = Left(sPath, iWidth - Len(sFileName)) & sFileName
End Function
 

sxschech

Registered User.
Local time
Yesterday, 18:53
Joined
Mar 2, 2010
Messages
792
Another option might be to change the point size of the font in the text box. If it is Calibri 11, try Calibri 08? Of course if the name or path are very long, that still may not be sufficient to display the text.
 

Users who are viewing this thread

Top Bottom