Solved

Scheduler expand text box question

Posted on 2013-01-11
31
430 Views
Last Modified: 2013-01-12
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
0
Comment
Question by:chestera
  • 11
  • 11
  • 9
31 Comments
 
LVL 61

Expert Comment

by:mbizup
ID: 38769334
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
 
LVL 61

Assisted Solution

by:mbizup
mbizup earned 250 total points
ID: 38769337
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
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38769347
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
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38769351
Looks like Miriam already corrected herself.
:-)
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38769354
:-)

I figured having the textbox visibly scooting around the screen would drive the users to distraction.
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38769356
Maybe it will seem like a game.  Much better if you move the textbox around when the mouse approaches.
;-)
0
 
LVL 29

Accepted Solution

by:
IrogSinta earned 250 total points
ID: 38769367
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
 

Author Comment

by:chestera
ID: 38769417
irogsinta

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

chestera
0
 

Author Comment

by:chestera
ID: 38769422
mbizup

Thank you for that

chestera
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38769427
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38769451
Miriam,
I want to see what you did but I only have 2007.  
:-(
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38770093
Ron,

I've updated my comment with it in .mdb format.
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38770394
Thanks Miriam,
I'll check it tonight when I get home. I'm up in Richmond for my son's gymnastic competition.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38770472
Woot! Have fun with that.

It sounds like we might be neighbors.
0
 

Author Comment

by:chestera
ID: 38770624
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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Comment

by:chestera
ID: 38770636
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
 
LVL 61

Expert Comment

by:mbizup
ID: 38770637
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
 
LVL 61

Expert Comment

by:mbizup
ID: 38770640
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
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38770647
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
 
LVL 61

Expert Comment

by:mbizup
ID: 38770654
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
 

Author Comment

by:chestera
ID: 38770703
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
 

Author Comment

by:chestera
ID: 38770706
IrogSinta

Thank you again most appreciated

Alan
0
 

Author Comment

by:chestera
ID: 38770744
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
 
LVL 61

Expert Comment

by:mbizup
ID: 38770788
Chestera,

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

Author Comment

by:chestera
ID: 38770935
mbizup

Ok thank you. Didn't know it existed

Alan
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38770954
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
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38771010
Miriam,
You did have time on your hands.  Cool beans!
 :-)
0
 

Author Comment

by:chestera
ID: 38771054
mbizup

Yep it worked Shift F2. Learn something new every day

Alan
0
 

Author Comment

by:chestera
ID: 38771059
IrogSinta

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

Alan
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38771084
-->> 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
 

Author Comment

by:chestera
ID: 38771322
mbizup

Thank you for all your help all the best
Alan
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Format vertical text in Access 2016 3 32
Running sum query 6 32
Newbie needs help printing from a form. 10 20
Excess tables to Excel BackUp 3 29
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now