Solved

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

Posted on 2007-11-23
10
1,105 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Author Comment

by:michaelrobertfrench
Comment Utility
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
Comment Utility
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 175 total points
Comment Utility
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
Comment Utility
^That time, without the crazy characters!
.\_/.
0
 
LVL 44

Accepted Solution

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

Author Closing Comment

by:michaelrobertfrench
Comment Utility
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
Comment Utility
Thank You
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now