PC Review


Reply
Thread Tools Rate Thread

changing size of textbox to match form

 
 
Phil Reynolds
Guest
Posts: n/a
 
      25th Oct 2007
I have a single text box (a large one) in a form that pops up. I want the
text box to change size as the user changes the size of the form. However,
doing me.txtbox.width = me.width doesn't work, as the width value of the
form doesn't seem to change, even as the form is resized by the user.

How can get the textbox to always be the same size as the form that contains
it?


 
Reply With Quote
 
 
 
 
Rick Brandt
Guest
Posts: n/a
 
      25th Oct 2007
Phil Reynolds wrote:
> I have a single text box (a large one) in a form that pops up. I want
> the text box to change size as the user changes the size of the form.
> However, doing me.txtbox.width = me.width doesn't work, as the width
> value of the form doesn't seem to change, even as the form is resized
> by the user.
> How can get the textbox to always be the same size as the form that
> contains it?


First, realize that the user is not resizing the form. They are resizing
the *window* that the form is hosted in and that IS different.

You can use the Resize event of the form (confusing I know), and when the
window is made larger you will first have to make the form section where
the TextBox resides wider and/or taller and then resize the TextBox. If the
form is made smaller you have to first resize the TextBox and then resize
the form section. Doing these in the wrong order will cause an error. You
cannot make the TextBox domensions extend beyond the section and you cannot
make the section so small that it infringes on space already being used by
the TextBox. It gets a bit more complicated because in one move the user
can make the width smaller while making the height greater or vise-versa.

All of these adjustments will be relative to the InsideHeight and
InsideWidth properties of the form.

I do this fairly often so users with higher resolution displays can make a
parent form taller so that they see more rows of a continuous subform than
the default. I also save the size in a table per user so that the form
opens that size the next time.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


 
Reply With Quote
 
Phil Reynolds
Guest
Posts: n/a
 
      25th Oct 2007
Thanks, Rick, that's what I needed.

"Rick Brandt" <(E-Mail Removed)> wrote in message
news:if0Ui.2370$(E-Mail Removed)...
> Phil Reynolds wrote:
>> I have a single text box (a large one) in a form that pops up. I want
>> the text box to change size as the user changes the size of the form.
>> However, doing me.txtbox.width = me.width doesn't work, as the width
>> value of the form doesn't seem to change, even as the form is resized
>> by the user.
>> How can get the textbox to always be the same size as the form that
>> contains it?

>
> First, realize that the user is not resizing the form. They are resizing
> the *window* that the form is hosted in and that IS different.
>
> You can use the Resize event of the form (confusing I know), and when the
> window is made larger you will first have to make the form section where
> the TextBox resides wider and/or taller and then resize the TextBox. If
> the form is made smaller you have to first resize the TextBox and then
> resize the form section. Doing these in the wrong order will cause an
> error. You cannot make the TextBox domensions extend beyond the section
> and you cannot make the section so small that it infringes on space
> already being used by the TextBox. It gets a bit more complicated because
> in one move the user can make the width smaller while making the height
> greater or vise-versa.
>
> All of these adjustments will be relative to the InsideHeight and
> InsideWidth properties of the form.
>
> I do this fairly often so users with higher resolution displays can make a
> parent form taller so that they see more rows of a continuous subform than
> the default. I also save the size in a table per user so that the form
> opens that size the next time.
>
> --
> Rick Brandt, Microsoft Access MVP
> Email (as appropriate) to...
> RBrandt at Hunter dot com
>



 
Reply With Quote
 
Phil Reynolds
Guest
Posts: n/a
 
      4th Nov 2007
Hey, Rick. One more question for you. If I want to close and reopen the form
when the user moves to a new record, how can I place the form in the same
position on the screen as it was before it was closed. In other words, the
user has this pop-up form open; they move to a new record; the OnCurrent
event closes the form, then reopens it, using the InsideHeight and
InsideWidth properties to resize the form to how it was before it was
closed. But how put it in the same place on the screen where it was before
it was closed? Thanks.

"Rick Brandt" <(E-Mail Removed)> wrote in message
news:if0Ui.2370$(E-Mail Removed)...
> Phil Reynolds wrote:
>> I have a single text box (a large one) in a form that pops up. I want
>> the text box to change size as the user changes the size of the form.
>> However, doing me.txtbox.width = me.width doesn't work, as the width
>> value of the form doesn't seem to change, even as the form is resized
>> by the user.
>> How can get the textbox to always be the same size as the form that
>> contains it?

>
> First, realize that the user is not resizing the form. They are resizing
> the *window* that the form is hosted in and that IS different.
>
> You can use the Resize event of the form (confusing I know), and when the
> window is made larger you will first have to make the form section where
> the TextBox resides wider and/or taller and then resize the TextBox. If
> the form is made smaller you have to first resize the TextBox and then
> resize the form section. Doing these in the wrong order will cause an
> error. You cannot make the TextBox domensions extend beyond the section
> and you cannot make the section so small that it infringes on space
> already being used by the TextBox. It gets a bit more complicated because
> in one move the user can make the width smaller while making the height
> greater or vise-versa.
>
> All of these adjustments will be relative to the InsideHeight and
> InsideWidth properties of the form.
>
> I do this fairly often so users with higher resolution displays can make a
> parent form taller so that they see more rows of a continuous subform than
> the default. I also save the size in a table per user so that the form
> opens that size the next time.
>
> --
> Rick Brandt, Microsoft Access MVP
> Email (as appropriate) to...
> RBrandt at Hunter dot com
>



 
Reply With Quote
 
BruceM
Guest
Posts: n/a
 
      5th Nov 2007
You can use the MoveSize function in the form's Open event. Help has more
information, but in general you would use the Top and Left arguments only,
and leave the Height and Width arguments blank since you have code to take
care of that.

"Phil Reynolds" <(E-Mail Removed)> wrote in message
news:zD8Xi.91$(E-Mail Removed)...
> Hey, Rick. One more question for you. If I want to close and reopen the
> form when the user moves to a new record, how can I place the form in the
> same position on the screen as it was before it was closed. In other
> words, the user has this pop-up form open; they move to a new record; the
> OnCurrent event closes the form, then reopens it, using the InsideHeight
> and InsideWidth properties to resize the form to how it was before it was
> closed. But how put it in the same place on the screen where it was before
> it was closed? Thanks.
>
> "Rick Brandt" <(E-Mail Removed)> wrote in message
> news:if0Ui.2370$(E-Mail Removed)...
>> Phil Reynolds wrote:
>>> I have a single text box (a large one) in a form that pops up. I want
>>> the text box to change size as the user changes the size of the form.
>>> However, doing me.txtbox.width = me.width doesn't work, as the width
>>> value of the form doesn't seem to change, even as the form is resized
>>> by the user.
>>> How can get the textbox to always be the same size as the form that
>>> contains it?

>>
>> First, realize that the user is not resizing the form. They are resizing
>> the *window* that the form is hosted in and that IS different.
>>
>> You can use the Resize event of the form (confusing I know), and when the
>> window is made larger you will first have to make the form section where
>> the TextBox resides wider and/or taller and then resize the TextBox. If
>> the form is made smaller you have to first resize the TextBox and then
>> resize the form section. Doing these in the wrong order will cause an
>> error. You cannot make the TextBox domensions extend beyond the section
>> and you cannot make the section so small that it infringes on space
>> already being used by the TextBox. It gets a bit more complicated
>> because in one move the user can make the width smaller while making the
>> height greater or vise-versa.
>>
>> All of these adjustments will be relative to the InsideHeight and
>> InsideWidth properties of the form.
>>
>> I do this fairly often so users with higher resolution displays can make
>> a parent form taller so that they see more rows of a continuous subform
>> than the default. I also save the size in a table per user so that the
>> form opens that size the next time.
>>
>> --
>> Rick Brandt, Microsoft Access MVP
>> Email (as appropriate) to...
>> RBrandt at Hunter dot com
>>

>
>



 
Reply With Quote
 
Phil Reynolds
Guest
Posts: n/a
 
      6th Nov 2007
Right -- but how would I get the Top and Left values for the window before I
close it, so I can restore those values?

"BruceM" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> You can use the MoveSize function in the form's Open event. Help has more
> information, but in general you would use the Top and Left arguments only,
> and leave the Height and Width arguments blank since you have code to take
> care of that.
>
> "Phil Reynolds" <(E-Mail Removed)> wrote in message
> news:zD8Xi.91$(E-Mail Removed)...
>> Hey, Rick. One more question for you. If I want to close and reopen the
>> form when the user moves to a new record, how can I place the form in the
>> same position on the screen as it was before it was closed. In other
>> words, the user has this pop-up form open; they move to a new record; the
>> OnCurrent event closes the form, then reopens it, using the InsideHeight
>> and InsideWidth properties to resize the form to how it was before it was
>> closed. But how put it in the same place on the screen where it was
>> before it was closed? Thanks.
>>
>> "Rick Brandt" <(E-Mail Removed)> wrote in message
>> news:if0Ui.2370$(E-Mail Removed)...
>>> Phil Reynolds wrote:
>>>> I have a single text box (a large one) in a form that pops up. I want
>>>> the text box to change size as the user changes the size of the form.
>>>> However, doing me.txtbox.width = me.width doesn't work, as the width
>>>> value of the form doesn't seem to change, even as the form is resized
>>>> by the user.
>>>> How can get the textbox to always be the same size as the form that
>>>> contains it?
>>>
>>> First, realize that the user is not resizing the form. They are
>>> resizing the *window* that the form is hosted in and that IS different.
>>>
>>> You can use the Resize event of the form (confusing I know), and when
>>> the window is made larger you will first have to make the form section
>>> where the TextBox resides wider and/or taller and then resize the
>>> TextBox. If the form is made smaller you have to first resize the
>>> TextBox and then resize the form section. Doing these in the wrong
>>> order will cause an error. You cannot make the TextBox domensions
>>> extend beyond the section and you cannot make the section so small that
>>> it infringes on space already being used by the TextBox. It gets a bit
>>> more complicated because in one move the user can make the width smaller
>>> while making the height greater or vise-versa.
>>>
>>> All of these adjustments will be relative to the InsideHeight and
>>> InsideWidth properties of the form.
>>>
>>> I do this fairly often so users with higher resolution displays can make
>>> a parent form taller so that they see more rows of a continuous subform
>>> than the default. I also save the size in a table per user so that the
>>> form opens that size the next time.
>>>
>>> --
>>> Rick Brandt, Microsoft Access MVP
>>> Email (as appropriate) to...
>>> RBrandt at Hunter dot com
>>>

>>
>>

>
>



 
Reply With Quote
 
BruceM
Guest
Posts: n/a
 
      6th Nov 2007
You can use the WindowLeft and WindowTop properties to determine the values
needed for the first two arguments in the MoveSize property. Define the
variables in a standard module:
Public lngLeft As Long
Public lngTop As Long

Assign values in the form's Close event:
lngLeft = Me.WindowLeft
lngTop = Me.WindowTop

In the form's Open event:
DoCmd.MoveSize lngLeft, lngTop

If the values need to be stored for another session they would need to be
stored in a table rather than in a variable.

Storing the values should work in a split database in which every user has a
separate front end. I think you can have front-end tables in a split
database, but I am not certain how that works. If the database is not
split, and if it can have several users at once, it could become tricky to
set the values in such a way that each user will have customized settings.

Using the variables to store the values for the current session will
likewise become complex, I think, in a multi-user environment in which there
is no user-specific login and the database is not split. If this is an
issue in a multi-user environment, post details of the situation.

"Phil Reynolds" <(E-Mail Removed)> wrote in message
news:gkPXi.53004$(E-Mail Removed)...
> Right -- but how would I get the Top and Left values for the window before
> I close it, so I can restore those values?
>
> "BruceM" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> You can use the MoveSize function in the form's Open event. Help has
>> more information, but in general you would use the Top and Left arguments
>> only, and leave the Height and Width arguments blank since you have code
>> to take care of that.
>>
>> "Phil Reynolds" <(E-Mail Removed)> wrote in message
>> news:zD8Xi.91$(E-Mail Removed)...
>>> Hey, Rick. One more question for you. If I want to close and reopen the
>>> form when the user moves to a new record, how can I place the form in
>>> the same position on the screen as it was before it was closed. In other
>>> words, the user has this pop-up form open; they move to a new record;
>>> the OnCurrent event closes the form, then reopens it, using the
>>> InsideHeight and InsideWidth properties to resize the form to how it was
>>> before it was closed. But how put it in the same place on the screen
>>> where it was before it was closed? Thanks.
>>>
>>> "Rick Brandt" <(E-Mail Removed)> wrote in message
>>> news:if0Ui.2370$(E-Mail Removed)...
>>>> Phil Reynolds wrote:
>>>>> I have a single text box (a large one) in a form that pops up. I want
>>>>> the text box to change size as the user changes the size of the form.
>>>>> However, doing me.txtbox.width = me.width doesn't work, as the width
>>>>> value of the form doesn't seem to change, even as the form is resized
>>>>> by the user.
>>>>> How can get the textbox to always be the same size as the form that
>>>>> contains it?
>>>>
>>>> First, realize that the user is not resizing the form. They are
>>>> resizing the *window* that the form is hosted in and that IS
>>>> different.
>>>>
>>>> You can use the Resize event of the form (confusing I know), and when
>>>> the window is made larger you will first have to make the form section
>>>> where the TextBox resides wider and/or taller and then resize the
>>>> TextBox. If the form is made smaller you have to first resize the
>>>> TextBox and then resize the form section. Doing these in the wrong
>>>> order will cause an error. You cannot make the TextBox domensions
>>>> extend beyond the section and you cannot make the section so small that
>>>> it infringes on space already being used by the TextBox. It gets a bit
>>>> more complicated because in one move the user can make the width
>>>> smaller while making the height greater or vise-versa.
>>>>
>>>> All of these adjustments will be relative to the InsideHeight and
>>>> InsideWidth properties of the form.
>>>>
>>>> I do this fairly often so users with higher resolution displays can
>>>> make a parent form taller so that they see more rows of a continuous
>>>> subform than the default. I also save the size in a table per user so
>>>> that the form opens that size the next time.
>>>>
>>>> --
>>>> Rick Brandt, Microsoft Access MVP
>>>> Email (as appropriate) to...
>>>> RBrandt at Hunter dot com
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
DavidB
Guest
Posts: n/a
 
      6th Nov 2007
> If the database is not split, and if it can have several users at once, it could become tricky to
> set the values in such a way that each user will have customized settings.



If so you have MUCH bigger issues than form resizing. In such a
situation it is not IF your database will become corrupted but WHEN.

 
Reply With Quote
 
Phil Reynolds
Guest
Posts: n/a
 
      7th Nov 2007
Thanks!

"BruceM" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> You can use the WindowLeft and WindowTop properties to determine the
> values needed for the first two arguments in the MoveSize property.
> Define the variables in a standard module:
> Public lngLeft As Long
> Public lngTop As Long
>
> Assign values in the form's Close event:
> lngLeft = Me.WindowLeft
> lngTop = Me.WindowTop
>
> In the form's Open event:
> DoCmd.MoveSize lngLeft, lngTop
>
> If the values need to be stored for another session they would need to be
> stored in a table rather than in a variable.
>
> Storing the values should work in a split database in which every user has
> a separate front end. I think you can have front-end tables in a split
> database, but I am not certain how that works. If the database is not
> split, and if it can have several users at once, it could become tricky to
> set the values in such a way that each user will have customized settings.
>
> Using the variables to store the values for the current session will
> likewise become complex, I think, in a multi-user environment in which
> there is no user-specific login and the database is not split. If this is
> an issue in a multi-user environment, post details of the situation.
>
> "Phil Reynolds" <(E-Mail Removed)> wrote in message
> news:gkPXi.53004$(E-Mail Removed)...
>> Right -- but how would I get the Top and Left values for the window
>> before I close it, so I can restore those values?
>>
>> "BruceM" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> You can use the MoveSize function in the form's Open event. Help has
>>> more information, but in general you would use the Top and Left
>>> arguments only, and leave the Height and Width arguments blank since you
>>> have code to take care of that.
>>>
>>> "Phil Reynolds" <(E-Mail Removed)> wrote in message
>>> news:zD8Xi.91$(E-Mail Removed)...
>>>> Hey, Rick. One more question for you. If I want to close and reopen the
>>>> form when the user moves to a new record, how can I place the form in
>>>> the same position on the screen as it was before it was closed. In
>>>> other words, the user has this pop-up form open; they move to a new
>>>> record; the OnCurrent event closes the form, then reopens it, using the
>>>> InsideHeight and InsideWidth properties to resize the form to how it
>>>> was before it was closed. But how put it in the same place on the
>>>> screen where it was before it was closed? Thanks.
>>>>
>>>> "Rick Brandt" <(E-Mail Removed)> wrote in message
>>>> news:if0Ui.2370$(E-Mail Removed)...
>>>>> Phil Reynolds wrote:
>>>>>> I have a single text box (a large one) in a form that pops up. I want
>>>>>> the text box to change size as the user changes the size of the form.
>>>>>> However, doing me.txtbox.width = me.width doesn't work, as the width
>>>>>> value of the form doesn't seem to change, even as the form is resized
>>>>>> by the user.
>>>>>> How can get the textbox to always be the same size as the form that
>>>>>> contains it?
>>>>>
>>>>> First, realize that the user is not resizing the form. They are
>>>>> resizing the *window* that the form is hosted in and that IS
>>>>> different.
>>>>>
>>>>> You can use the Resize event of the form (confusing I know), and when
>>>>> the window is made larger you will first have to make the form
>>>>> section where the TextBox resides wider and/or taller and then resize
>>>>> the TextBox. If the form is made smaller you have to first resize the
>>>>> TextBox and then resize the form section. Doing these in the wrong
>>>>> order will cause an error. You cannot make the TextBox domensions
>>>>> extend beyond the section and you cannot make the section so small
>>>>> that it infringes on space already being used by the TextBox. It gets
>>>>> a bit more complicated because in one move the user can make the width
>>>>> smaller while making the height greater or vise-versa.
>>>>>
>>>>> All of these adjustments will be relative to the InsideHeight and
>>>>> InsideWidth properties of the form.
>>>>>
>>>>> I do this fairly often so users with higher resolution displays can
>>>>> make a parent form taller so that they see more rows of a continuous
>>>>> subform than the default. I also save the size in a table per user so
>>>>> that the form opens that size the next time.
>>>>>
>>>>> --
>>>>> Rick Brandt, Microsoft Access MVP
>>>>> Email (as appropriate) to...
>>>>> RBrandt at Hunter dot com
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Phil Reynolds
Guest
Posts: n/a
 
      11th Nov 2007
Actually, that doesn't work. There is not WindowLeft or WindowTop property
of a form in Access 2000. Those properties are not listed in the help
either.

So I'm still stuck with needing to know how to get the Top and Left values
for a window before I close it, so that I can restore those values when it's
reopened.


"BruceM" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> You can use the WindowLeft and WindowTop properties to determine the
> values needed for the first two arguments in the MoveSize property.
> Define the variables in a standard module:
> Public lngLeft As Long
> Public lngTop As Long
>
> Assign values in the form's Close event:
> lngLeft = Me.WindowLeft
> lngTop = Me.WindowTop
>
> In the form's Open event:
> DoCmd.MoveSize lngLeft, lngTop
>
> If the values need to be stored for another session they would need to be
> stored in a table rather than in a variable.
>
> Storing the values should work in a split database in which every user has
> a separate front end. I think you can have front-end tables in a split
> database, but I am not certain how that works. If the database is not
> split, and if it can have several users at once, it could become tricky to
> set the values in such a way that each user will have customized settings.
>
> Using the variables to store the values for the current session will
> likewise become complex, I think, in a multi-user environment in which
> there is no user-specific login and the database is not split. If this is
> an issue in a multi-user environment, post details of the situation.
>
> "Phil Reynolds" <(E-Mail Removed)> wrote in message
> news:gkPXi.53004$(E-Mail Removed)...
>> Right -- but how would I get the Top and Left values for the window
>> before I close it, so I can restore those values?
>>
>> "BruceM" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> You can use the MoveSize function in the form's Open event. Help has
>>> more information, but in general you would use the Top and Left
>>> arguments only, and leave the Height and Width arguments blank since you
>>> have code to take care of that.
>>>
>>> "Phil Reynolds" <(E-Mail Removed)> wrote in message
>>> news:zD8Xi.91$(E-Mail Removed)...
>>>> Hey, Rick. One more question for you. If I want to close and reopen the
>>>> form when the user moves to a new record, how can I place the form in
>>>> the same position on the screen as it was before it was closed. In
>>>> other words, the user has this pop-up form open; they move to a new
>>>> record; the OnCurrent event closes the form, then reopens it, using the
>>>> InsideHeight and InsideWidth properties to resize the form to how it
>>>> was before it was closed. But how put it in the same place on the
>>>> screen where it was before it was closed? Thanks.
>>>>
>>>> "Rick Brandt" <(E-Mail Removed)> wrote in message
>>>> news:if0Ui.2370$(E-Mail Removed)...
>>>>> Phil Reynolds wrote:
>>>>>> I have a single text box (a large one) in a form that pops up. I want
>>>>>> the text box to change size as the user changes the size of the form.
>>>>>> However, doing me.txtbox.width = me.width doesn't work, as the width
>>>>>> value of the form doesn't seem to change, even as the form is resized
>>>>>> by the user.
>>>>>> How can get the textbox to always be the same size as the form that
>>>>>> contains it?
>>>>>
>>>>> First, realize that the user is not resizing the form. They are
>>>>> resizing the *window* that the form is hosted in and that IS
>>>>> different.
>>>>>
>>>>> You can use the Resize event of the form (confusing I know), and when
>>>>> the window is made larger you will first have to make the form
>>>>> section where the TextBox resides wider and/or taller and then resize
>>>>> the TextBox. If the form is made smaller you have to first resize the
>>>>> TextBox and then resize the form section. Doing these in the wrong
>>>>> order will cause an error. You cannot make the TextBox domensions
>>>>> extend beyond the section and you cannot make the section so small
>>>>> that it infringes on space already being used by the TextBox. It gets
>>>>> a bit more complicated because in one move the user can make the width
>>>>> smaller while making the height greater or vise-versa.
>>>>>
>>>>> All of these adjustments will be relative to the InsideHeight and
>>>>> InsideWidth properties of the form.
>>>>>
>>>>> I do this fairly often so users with higher resolution displays can
>>>>> make a parent form taller so that they see more rows of a continuous
>>>>> subform than the default. I also save the size in a table per user so
>>>>> that the form opens that size the next time.
>>>>>
>>>>> --
>>>>> Rick Brandt, Microsoft Access MVP
>>>>> Email (as appropriate) to...
>>>>> RBrandt at Hunter dot com
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
changing size of textbox to match form Phil Reynolds Microsoft Access Forms 16 12th Nov 2007 03:15 PM
changing size of textbox to match form Phil Reynolds Microsoft Access Form Coding 16 12th Nov 2007 03:15 PM
Programmatically changing the size of a textbox Bill Gower Microsoft Dot NET Framework Forms 1 20th Jul 2007 09:56 AM
Changing cursor size in textbox?? Dave Microsoft ASP .NET 2 11th Nov 2004 02:35 PM
Changing browser size to match the size of site =?Utf-8?B?SmFjayBTcGFycm93?= Microsoft Frontpage 2 16th Feb 2004 11:12 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:21 AM.