Auto-adjust size of memo field? (1 Viewer)

Fritzo

New member
Local time
Today, 21:06
Joined
Jan 8, 2007
Messages
1
Is it possible to make sure that the size of a memo field in a form is automaticly adjusted according to the length of the text that the field contains?
I know I can use the scrollbar(s) to read the whole text, but I don't want these in my form. I just want a memo field to show the entire text, no matter how long the text is. :confused:
 

Keith Nichols

Registered User.
Local time
Today, 22:06
Joined
Jan 27, 2006
Messages
431
I would have expected the can grow property to do just what you required but a quick test on my home PC didn't work (A2k). I have only used can grow on reports.

I will be interested to find out if the can grow should work in this situation.

Sorry I can't be of any direct help :)
 

neileg

AWF VIP
Local time
Today, 20:06
Joined
Dec 4, 2002
Messages
5,975
Fritzo said:
I just want a memo field to show the entire text, no matter how long the text is.
This would potentially require the form to resize dynamically as you scrolled from record to record, if the text box size exceeded the space on the form. Utilmately, you could have a memo field too large to display on screen. So I don't think this dynamic resizing is supported.

But cleverer people than me may have a solution...
 

johncallaghan

Registered User.
Local time
Today, 20:06
Joined
Sep 12, 2005
Messages
40
<shift><F2> will make the textbox popup.

I hope this helps

Cheers

John
 

gold007eye

Registered User.
Local time
Today, 15:06
Joined
May 11, 2005
Messages
260
Another solutions you could use is the acZoomBox command. Set it as an Event Procedure on the "Double Click" command. Then you wouldn't have to worry about scrollbars on your form if the text didn't fit the form.
 

missinglinq

AWF VIP
Local time
Today, 15:06
Joined
Jun 20, 2003
Messages
6,423
As Keith found out, Can Grow is only available on forms. The usual winner, when this question comes up, is Gold007eye's suggestion. The following code is placed in the MouseMove event, but can be used in the Double-Click event, as suggested by Gold007eye (I also use the double-click a lot) or even in the GotFocus event.

Code:
Private Sub YourTextBox_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
   If Not IsNull(YourTextBox) Then 
      YourTextBox.SetFocus
      DoCmd.RunCommand acCmdZoomBox
   End If
End Sub

Some people object to this code because they're forced to move to the side of the box to click on the close button, and because Access is deciding both the size and the placement of the zoomed box. The cmdZoomBox also opens up with all the text selected, which can be dangerous, as hitting any key will now delete the data.

Here's some code to ape the effect of the cmdZoomBox, but allowing the developer to decide on the size and placement of the box, eliminating the danger of having all the text selected, and allowing the box to be closed by double-clicking anywhere within the zoomed box.

Just place a large text box (call it Zoombox) on your form. Size the box as you like and place it on the form where you want it to appear. Assign it the same Control Source as the field you are going to expand.

Substitute the actual name of your field to be expanded for YourFieldName.

Code:
Private Sub Form_Load()
     'Make the textbox invisible on loading the form    
      Zoombox.Visible = False
End Sub

Private Sub YourTextBox_DblClick(Cancel As Integer)
    'When you double click the field, make the ZoomBox
        'visible and move the cursor to the end of the text
        Zoombox.Visible = True
        Zoombox.SetFocus    
        Zoombox.SelStart = Len(Me.Zoombox.Value)
End Sub

Private Sub Zoombox_DblClick(Cancel As Integer)
        'Double click the ZoomBox to close it and
        'return to your original field
    Me.YourTextBox.SetFocus
    Zoombox.Visible = False
End Sub

Now to expand your text box simply double-click on it. It pops up where you want it to and the just the size you want. Look you text over, editing it if you like, then double-click anywhere within the box to close it.
 

cdoyle

Registered User.
Local time
Today, 12:06
Joined
Jun 9, 2004
Messages
383
I've been trying to use the zoom feature, and it works but it also causes a problem.

When I move the mouse over the memofield it opens the popup just like it's suppose too. But it puts the popup right over the field, and the 'cancel' button is almost on top of the field, so when the user clicks cancel. It closes the window but now the users mouse is right over the memo field again, so it opens the popup again.

Does the zoom work with onclick? I can't seem to get it to work? Or is there a way in the code to move where the popup appears?

Thanks
 

cdoyle

Registered User.
Local time
Today, 12:06
Joined
Jun 9, 2004
Messages
383
Or does anyone have any code that would allow the memo-box to grow when there is more text then the size of the box?
 

gold007eye

Registered User.
Local time
Today, 15:06
Joined
May 11, 2005
Messages
260
cdoyle: If you had read my reply about 3 or 4 posts up I suggest you using it on the "Doubl-Click" or "Click" event. Try this out.

"Another solutions you could use is the acZoomBox command. Set it as an Event Procedure on the "Double Click" command. Then you wouldn't have to worry about scrollbars on your form if the text didn't fit the form."
 

cdoyle

Registered User.
Local time
Today, 12:06
Joined
Jun 9, 2004
Messages
383
I had tried the on_click but it wasn't working.

I just tried it again, and now I got it to work. I must have not copied something right the first time.
 

Users who are viewing this thread

Top Bottom