retrieve columnwidth a sub form before closing

  • Thread starter Thread starter Nhan
  • Start date Start date
N

Nhan

Hi,
problem:
my subform in sheet view stay the same, each time when displaying, the
columnwidth is not changed as I did at the last time. I think, the reason
is, Subform is an instance of a form, it can't "remember" the columnwidth
informs.

Now I want to save the columnwidth of each column in a table, before the
form is closed. But the property columnwidth of a control returns me always
the same value, althought I have changed the width of the concerned column.
Why?

I can explain, that this property returns the old value, not the current
value. ??
But then how can I retrieve the current size of a column? (of a subform)

Thanks for help
Nhan
 
Nhan,

I would try setting the ColumWidth property for each column in code
first. Then, save the values. This is how I do it, probably because of
the behavior you describe.

-Ken
 
Hi Ken,
I can't understand you. That was your answer to my question?
- I change size of a column (for example to 100), the old value is 200
- the form is now closing, I retrieve the width or this column, lValue =
ctrl.Columnwidth, but lValue is always 200. That means the property
Columnwidth in this case doesn't return the current width.

Nhan
 
Nhan,

To be more clear, I:

1) Open the form, which must be in DataSheet view. If it is in Single
Form or Continuous Form view, column widths mean nothing.
2) Set the ColumnWidths in code. I use the Form_DblClick event to run a
routine which sets the widths. I change the values until the columns
look the way I want. This way I have numeric values for the widths in
code.
3) Save the form. If you don't do this, the new widths will be lost.

Step 3 is perhaps what you are missing. Also, if you save the form when
you exit, the column widths should also be saved with it. Saving won't
work for an MDE file.

If saving the form doesn't work, you may need to upgrade to the latest
service pack, because the behavior you describe is not normal.

-Ken
 
I think Nhan wants to capture the column width when it has been changed
interactively by the user, rather than when it has been changed by his code.
If that's so, and if, as Nhan describes, the ColumnWidth property always
returns the original value (I have not tested that) then I'm afraid I don't
have an answer.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Ken,
Excuse me, that was my code error.
I forgot to write:
rs.edit
before I save the value to recordset:
rs!Width = ctrl.columnwidth
rs.update

but there was no error message. Why? But that is another question.
Thanks again.
Nhan
 
Brendan Reynolds said:
I think Nhan wants to capture the column width when it has been changed
interactively by the user, rather than when it has been changed by his code.

Yes

If that's so, and if, as Nhan describes, the ColumnWidth property always
returns the original value (I have not tested that) then I'm afraid I don't
have an answer.

But it was my error. See my post to Ken

Thanks
Nhan
 
Ah, I see. Guess I should have tested! Well, congratulations to you and Ken
for sorting it out! :-)

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Back
Top