Solved

Access Database - Unable to force a datasheet form to have a fixed width for text box.

Posted on 2007-11-23
10
1,113 Views
Last Modified: 2013-12-05
I have a form.  On this form there is a subform.  On this subform there is another form that is a datasheet.
My problem is this:  How can I force the width of the text box on this datasheet to be a certain size without code and the accompaning overhead.  Basically the user can fiddle until the column width is 0 thus the field will no longer show.  

I coded a Current Event (see below) but it seems this is a lot of everhead.  BTW - this is an unbound .adp against a SQL Server - so I am looking for the least overhead possible since this thing is getting hit by 250 users.

Private Sub Form_Current()
    Forms!frmMain.frmA.Form.Controls(0).ColumnWidth = 500
    Forms!frmMain.frmA.Form.Controls(1).ColumnWidth = 2000
End Sub
0
Comment
Question by:michaelrobertfrench
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 44

Assisted Solution

by:GRayL
GRayL earned 100 total points
ID: 20340666
What you have written will set the column widths of the first two controls in the first subform, not the second. For that:

Private Sub Form_Current()
    Forms!frmMain.frmA.Form!frmB.Form.Controls(0).ColumnWidth = 500
    Forms!frmMain.frmA.Form!frmB.Form.Controls(1).ColumnWidth = 2000
End Sub
0
 

Author Comment

by:michaelrobertfrench
ID: 20340692
Actually I perhaps had my form - subform - datasheet a bit mixed up. Thanks for the clarity.
But that aside, the VBA with the .columnwidth property is what I am trying to avoid but see no property in the User Interface where I can set the width and have it retained.  Do you know how I can set the width without the overhead of code?
0
 
LVL 44

Expert Comment

by:GRayL
ID: 20340843
In Access, if you adjust the widths of a query in datasheet view and then save the query, when the query is re-run, the column widths are retained from the previous save.  This help?
0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

Author Comment

by:michaelrobertfrench
ID: 20340921
Access .adp unbound forms - forms are populated with stored procedures.  Still needing to know how to hardcode the width of the text box without VBA.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 20341698
michaelrobertfrench,

"hardcode"... "without VBA"

Isn't that an Oxymoron?
:)

Anyway...

If you don't want your users to "fiddle" with the column widths, then you could change the SubForm's DefaultView Property to: "Continuous Form" (Tabular).
Then squeeze all the controls together Horizontally, so they touch.
Then get rid of even the smallest empty spaces in the Detail Section of this subform.

This will create the illusion of Datasheet view, however, users can’t "fiddle".
;)

(The above technique is pretty standard here at EE)

Another benefit to this technique is that users will now be seeing the Caption Property of the Field, instead of the actual FieldName. (You can even change the text in the label to whatever you want)
So users will see: “Customer First Name” instead of “CUST_FN”

Hope this helps as well

JeffCoachman
0
 
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 175 total points
ID: 20341700
michaelrobertfrench,

"hardcode"... "without VBA"

Isn't that an Oxymoron?
:)

Anyway...

If you don't want your users to "fiddle" with the column widths, then you could change the SubForm's DefaultView Property to: "Continuous Form" (Tabular).
Then squeeze all the controls together Horizontally, so they touch.
Then get rid of even the smallest empty spaces in the Detail Section of this subform.

This will create the illusion of Datasheet view, however, users can't "fiddle".
;)

(The above technique is pretty standard here at EE)

Another benefit to this technique is that users will now be seeing the Caption Property of the Field, instead of the actual FieldName. (You can even change the text in the label to whatever you want)
So users will see: "Customer First Name" instead of "CUST_FN"

Hope this helps as well

JeffCoachman
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 20341712
^That time, without the crazy characters!
.\_/.
0
 
LVL 44

Accepted Solution

by:
Leigh Purvis earned 225 total points
ID: 20343380
Stephen Lebans Auto Column width (and datasheet column freezing).
http://www.lebans.com/autocolumnwidth.htm
0
 

Author Closing Comment

by:michaelrobertfrench
ID: 31410708
As far as I can determine - the vba must exist in order for the screen to have described properties.  Thanks
0
 

Author Comment

by:michaelrobertfrench
ID: 20856160
Thank You
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

856 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