Solved

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

Posted on 2007-11-23
10
1,111 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

773 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