Scheduler expand text box question

Hi EE

I have built a small monthly scheduler using the following code

Private Sub t1_GotFocus()  -----------Got Focus
FW = t1.Width
FH = t1.Height
Me.t1.Width = 5000
Me!t1.Height = 3000
End Sub

Private Sub t1_LostFocus()  ----------Lost Focus
Me.t1.Width = FW
Me!t1.Height = FH
End Sub

Private Sub t10_Click()   --------------------On Click
Me!txtDays = Controls("d" & 10).Value
Me!txtInfo = "10"
End Sub

The text box's expand from left to right. When I select the last box on the right hand side of the screen there isn't any room for the Box to expand. My question, is it possible to reverse the expansion  Right to left. Any help appreciated

chestera
chesteraAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

 
mbizupCommented:
Try this... you cant 'expand the textbox to the left', but you can move it left before expanding it.

Private Sub t1_GotFocus()  -----------Got Focus
FW = t1.Width
FL = t1.Left
FH = t1.Height
Me.t1.left = Me.t1.Left - 5000
Me.t1.Width = 5000

Me!t1.Height = 3000
End Sub

Open in new window


Private Sub t1_LostFocus()  ----------Lost Focus
Me.t1.Width = FW
Me.t1.Left = FL
Me!t1.Height = FH
End Sub

Open in new window

0
 
mbizupCommented:
This might be better...

Private Sub t1_GotFocus()  -----------Got Focus
FW = t1.Width
FL = t1.Left
FH = t1.Height
Me.t1.left = Me.t1.Left - (5000 - FW)
Me.t1.Width = 5000

Me!t1.Height = 3000
End Sub

Open in new window

0
 
IrogSintaCommented:
Slight modification to what mbizup posted so that the right side of the textbox stays in place.
Private Sub t1_GotFocus()  '-----------Got Focus
    FW = t1.Width
    FH = t1.Height
    FL = t1.Left
    Me.t1.Width = 5000
    Me!t1.Height = 3000
    Me.t1.Left = FL - (Me.t1.Width - FW)
End Sub

Open in new window

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
IrogSintaCommented:
Looks like Miriam already corrected herself.
:-)
0
 
mbizupCommented:
:-)

I figured having the textbox visibly scooting around the screen would drive the users to distraction.
0
 
IrogSintaCommented:
Maybe it will seem like a game.  Much better if you move the textbox around when the mouse approaches.
;-)
0
 
IrogSintaCommented:
chestera,
Do you repeat this same code for each of your textboxes?  If so, it would be better to just have each textbox call the same function.  Here's a sample code for 3 textboxes where the 3rd textbox expands to the left.

Private Sub t1_GotFocus()
    Call ExpandMe
End Sub
Private Sub t2_GotFocus()
    Call ExpandMe
End Sub
Private Sub t3_GotFocus()
    Call ExpandMe(True)
End Sub

Private Sub t1_LostFocus()
    Call ShrinkMe
End Sub
Private Sub t2_LostFocus()
    Call ShrinkMe
End Sub
Private Sub t3_LostFocus()
    Call ShrinkMe
End Sub

Private Sub ExpandMe(Optional expandLeft As Boolean)
    Dim ctl As Control
    
    Set ctl = Me.ActiveControl
    FW = ctl.Width
    FH = ctl.Height
    FL = ctl.Left
    ctl.Width = 5000
    ctl.Height = 3000
    If expandLeft Then ctl.Left = FL - (Me.t1.Width - FW)
    
End Sub

Private Sub ShrinkMe()
    Dim ctl As Control
    
    Set ctl = Me.ActiveControl
    ctl.Width = FW
    ctl.Height = FH
    ctl.Left = FL

End Sub

Open in new window

0

Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
 
chesteraAuthor Commented:
irogsinta

Than you for that Advice was going to change to call a function

chestera
0
 
chesteraAuthor Commented:
mbizup

Thank you for that

chestera
0
 
mbizupCommented:
0
 
IrogSintaCommented:
Miriam,
I want to see what you did but I only have 2007.  
:-(
0
 
mbizupCommented:
Ron,

I've updated my comment with it in .mdb format.
0
 
IrogSintaCommented:
Thanks Miriam,
I'll check it tonight when I get home. I'm up in Richmond for my son's gymnastic competition.
0
 
mbizupCommented:
Woot! Have fun with that.

It sounds like we might be neighbors.
0
 
chesteraAuthor Commented:
IrogSinta

Hope this is not out of order it now works fine right hand of the screen going right to left. I have now been trying to figure out how to change from Top to Bottom to bottom to Top. This is for the the last text box's at the bottom of the screen

regards
Alan
0
 
chesteraAuthor Commented:
mbizup

I have 31 box's on the screen representing the 31/30 days of the month (28 for Feb) they are quite small (Enough to put a heading for the reminder) when the user click on a day that box it expands to a large size so user can read/Add text. the field in the tbl is a memo field so thwer is no restriction on the amount of text ie 255 characters. Would you expand the box as the mouse movers over the box rather than click on the box

Thank you for your comment

Alan
0
 
mbizupCommented:
Responding, borrowing Ron's code because I'm right here...

Something like this:

Private Sub ExpandMe(ExpandUp as Boolean, expandLeft As Boolean)
    Dim ctl As Control
   
    Set ctl = Me.ActiveControl
    FW = ctl.Width
    FH = ctl.Height
    FL = ctl.Left
    FT = ctl.Top
    ctl.Width = 5000
    ctl.Height = 3000
    If expandLeft Then ctl.Left = FL - (Me.t1.Width - FW)
     If expandUp Then ctl.Top = FT   - (Me.t1.Height - FT)
End Sub
0
 
mbizupCommented:
Honestly, I would not bother with the expansions.

Have you tried Access's built-in ZoomBox feature?

Click on a control and hit Shift-F2 if memory serves me right.
0
 
IrogSintaCommented:
I noticed a mistake in my code. Just change this part as well.
  If expandLeft Then ctl.Left = FL - (ctl.Width - FW)
  If expandUp Then ctl.Top = FT   - (ctl.Height - FH)
0
 
mbizupCommented:
Something I have done in my own databases with similar issues (such as continuous forms with limited space with textboxes bound to memo fields) is to add this to the double-click event of any memo fields:

Docmd.runcommand accmdZoomBox

Open in new window


and simply instruct the users to double click the textbox if they want to enter text or see all the data in the field.
0
 
chesteraAuthor Commented:
mbizup

Many thanks for your help most appreciated. Re using the expansion I am using access 2003 so assume you are talking about 2010.

Alan
0
 
chesteraAuthor Commented:
IrogSinta

Thank you again most appreciated

Alan
0
 
chesteraAuthor Commented:
IrogSinta

Sorry to trouble you again. Not quite sure about the If statement
If expandLeft and the If expandUp should there be a value in variable  the expandleft and up

Alan
0
 
mbizupCommented:
Chestera,

I was actually not specifically referring to 2010.  The zoom box and that code should work in 2003
0
 
chesteraAuthor Commented:
mbizup

Ok thank you. Didn't know it existed

Alan
0
 
IrogSintaCommented:
Chestera,
Here's what it should look like:
Private Sub ExpandMe(Optional expandUp as Boolean, Optional expandLeft As Boolean)
    Dim ctl As Control
    
    Set ctl = Me.ActiveControl
    FW = ctl.Width
    FH = ctl.Height
    FL = ctl.Left
    FT = ctl.Top
    ctl.Width = 5000
    ctl.Height = 3000
    If expandLeft Then ctl.Left = FL - (ctl.Width - FW)
    If expandUp Then ctl.Top = FT - (ctl.Height - FH)
End Sub

Private Sub ShrinkMe()
    Dim ctl As Control
    
    Set ctl = Me.ActiveControl
    ctl.Width = FW
    ctl.Height = FH
    ctl.Left = FL
    ctl.Top = FT
End Sub

Open in new window

Most of your controls should use
Call ExpandMe
Controls on the right should use
Call ExpandMe(,True)
Controls on the bottom should use
Call ExpandMe(True)
The control on the bottom right that needs to expand left and up should use:
Call ExpandMe(True,True)
0
 
IrogSintaCommented:
Miriam,
You did have time on your hands.  Cool beans!
 :-)
0
 
chesteraAuthor Commented:
mbizup

Yep it worked Shift F2. Learn something new every day

Alan
0
 
chesteraAuthor Commented:
IrogSinta

Yep got that.  Many thanks again. You went above and beyond the question much appreciated.

Alan
0
 
mbizupCommented:
-->> Learn something new every day

Ain't it great?

The database I use that in is a Discrepancy Report Database with a mainform/subform setup.  The mainform shows the main trouble report; the subform displays all of the actions taken towards resolving the problem.  The users wanted to see the actions as a list... so that they could quickly see and enter information such as date, stats and description.  The description field however could be huge... and to keep it looking okay in a continuous subform, we could only display a small portion of the text.

So that zoombox was perfect, with the double-click event code "DoCmd.RunCommand acCmdZoomBox" (which is the VBA equivalent of Shift F2)
0
 
chesteraAuthor Commented:
mbizup

Thank you for all your help all the best
Alan
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.