DAO ColunmWidth

A

alex

DAO ColunmWidth

Hello,
Using Access ’03…

I create a table with DAO and open it (as a reference) for my users
behind a popup form.

I want to adjust the column widths to fit the size of the data
contained therein.

I have this code, which works when tested sans popup:

Function ColumnWidthTest()

Dim db As Database
Dim frm As Form
Dim ictl As Integer
Dim ctl As Control

Set db = CurrentDb
DoCmd.OpenTable ("MyTable")
Set frm = Screen.ActiveDatasheet
For ictl = 0 To frm.Controls.Count - 1
Set ctl = frm.Controls(ictl)
ctl.ColumnWidth = -2
Next ictl

End Function

The problem, however; is that there’s no active datasheet since it’s
opened behind/under a popup form. How can I modify the code above
(set frm reference) without using an “active” control?

Thanks,
alex
 
T

Tom van Stiphout

On Tue, 16 Mar 2010 05:05:10 -0700 (PDT), alex <[email protected]>
wrote:

Change:
Set frm = Screen.ActiveDatasheet
to:
Set frm = Forms!someForm

Determine the actual value of someForm by entering this in the
immediate window:
?forms.count
2
?forms(0).name
myForm1
?forms(1).name
myPopupForm2

You already know it's a REALLY BAD IDEA to show users a table, right?
Take a few extra minutes and show them a form in datasheet view.

-Tom.
Microsoft Access MVP
 
A

alex

Change:
Set frm = Screen.ActiveDatasheet
to:
Set frm = Forms!someForm

Determine the actual value of someForm by entering this in the
immediate window:
?forms.count
2
?forms(0).name
myForm1
?forms(1).name
myPopupForm2

You already know it's a REALLY BAD IDEA to show users a table, right?
Take a few extra minutes and show them a form in datasheet view.

-Tom.
Microsoft Access MVP














- Show quoted text -

Thanks Tom...I do know it's a bad idea to allow users access to the
table. In this situation, the table only shows results of a temp
querydef; the data are erased after every query! The popup is modal,
so they can't even touch it.

I would like to not have to create another form just to display data
when the table would work in this situation. In this case it truly
would be a useless object.
alex
 
D

Douglas J. Steele

I'd hardly call it useless, since it'll let you set the column width,
which is what you're trying to do.

Basically, there aren't many methods to work programmatically with tables,
since you're not supposed to!

--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/DJSteele
(no e-mails, please!)


Thanks Tom...I do know it's a bad idea to allow users access to the
table. In this situation, the table only shows results of a temp
querydef; the data are erased after every query! The popup is modal,
so they can't even touch it.

I would like to not have to create another form just to display data
when the table would work in this situation. In this case it truly
would be a useless object.
alex
 
A

alex

I'd  hardly call  it useless, since it'll let you set the column width,
which is what  you're trying to do.

Basically, there aren't many methods to work programmatically with tables,
since you're not supposed to!

--
Doug Steele, Microsoft Access MVPhttp://www.AccessMVP.com/DJSteele
(no e-mails, please!)



Thanks Tom...I do know it's a bad idea to allow users access to the
table.  In this situation, the table only shows results of a temp
querydef; the data are erased after every query!  The popup is modal,
so they can't even touch it.

I would like to not have to create another form just to display data
when the table would work in this situation.  In this case it truly
would be a useless object.
alex

Hi Doug,
I can adjust the column widths in a table's datasheet (which
technically is a form; right?).

The code I'm using (above), however, only allows it if the table
(datasheet) is active and not (in my case) inactive behind a popup.

Do you have any suggestions on how to modify the code above to work
with a table's datasheet?
alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top