Solved

Scheduler expand text box question

Posted on 2013-01-11
31
427 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Looks like Miriam already corrected herself.
:-)
0
 
LVL 61

Expert Comment

by:mbizup
Comment Utility
:-)

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

Expert Comment

by:IrogSinta
Comment Utility
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
Comment Utility
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
Comment Utility
irogsinta

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

chestera
0
 

Author Comment

by:chestera
Comment Utility
mbizup

Thank you for that

chestera
0
 
LVL 61

Expert Comment

by:mbizup
Comment Utility
0
 
LVL 29

Expert Comment

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

Expert Comment

by:mbizup
Comment Utility
Ron,

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

Expert Comment

by:IrogSinta
Comment Utility
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
Comment Utility
Woot! Have fun with that.

It sounds like we might be neighbors.
0
 

Author Comment

by:chestera
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:chestera
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
IrogSinta

Thank you again most appreciated

Alan
0
 

Author Comment

by:chestera
Comment Utility
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
Comment Utility
Chestera,

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

Author Comment

by:chestera
Comment Utility
mbizup

Ok thank you. Didn't know it existed

Alan
0
 
LVL 29

Expert Comment

by:IrogSinta
Comment Utility
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
Comment Utility
Miriam,
You did have time on your hands.  Cool beans!
 :-)
0
 

Author Comment

by:chestera
Comment Utility
mbizup

Yep it worked Shift F2. Learn something new every day

Alan
0
 

Author Comment

by:chestera
Comment Utility
IrogSinta

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

Alan
0
 
LVL 61

Expert Comment

by:mbizup
Comment Utility
-->> 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
Comment Utility
mbizup

Thank you for all your help all the best
Alan
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

771 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

12 Experts available now in Live!

Get 1:1 Help Now