473,387 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Allow/Deny saving of datasheet column widths and positions.

I want to allow users to resize and reposition columns of a datasheet
but for a prompt to be brought up and only the layout only to be saved
if they select "save changes". This is the way it works at the moment
for queries but for datasheet forms I find that it automatically saves
column positions and widths without prompting to save changes.

I should mention i am using Access 2000

Nov 5 '06 #1
5 7291

deekay wrote:
I want to allow users to resize and reposition columns of a datasheet
but for a prompt to be brought up and only the layout only to be saved
if they select "save changes". This is the way it works at the moment
for queries but for datasheet forms I find that it automatically saves
column positions and widths without prompting to save changes.

I should mention i am using Access 2000
I noticed one of way of doing this is when the prompt "do you want to
save changes to the design of form xxxxx" is brought up, but this is
only brought up when altering a form in design view and not in
datasheet view. Still looking for a way

Nov 5 '06 #2
To achieve what you want, you would need to create a table to hold the
user's preferences for each field.

Presumably you will add a Save Layout button to the toolbar for the
datasheet form, so that clicking this button saves the Column Order and
ColumnWidth for each column, information about which columns are frozen,
etc.

Then in the Open event of the form, you read the values from the table, and
assign them to the various columns, which effectively restores the form to
the user's last *saved* settings, rather than Access's last saved settings
for the form.

Here's an example of how to set the properties of the columns in the Open
event of the form:

Private Sub Form_Open(Cancel As Integer)
Me.RowHeight = -1

With Me.ClientNum
.ColumnHidden = False
.ColumnOrder = 1
.ColumnWidth = 864
End With

With Me.Surname
.ColumnHidden = False
.ColumnOrder = 2
.ColumnWidth = 2880
End With

With Me.Address
.ColumnHidden = False
.ColumnOrder = 4
.ColumnWidth = -2 'Set for visible text.
End With

RunCommand acCmdUnfreezeAllColumns
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"deekay" <de*****@gmail.comwrote in message
news:11********************@h54g2000cwb.googlegrou ps.com...
>
deekay wrote:
>I want to allow users to resize and reposition columns of a datasheet
but for a prompt to be brought up and only the layout only to be saved
if they select "save changes". This is the way it works at the moment
for queries but for datasheet forms I find that it automatically saves
column positions and widths without prompting to save changes.

I should mention i am using Access 2000

I noticed one of way of doing this is when the prompt "do you want to
save changes to the design of form xxxxx" is brought up, but this is
only brought up when altering a form in design view and not in
datasheet view. Still looking for a way

Nov 5 '06 #3
Thanks for the response I think this may the only way of doing it.
However what I would really like is something very simple like just
closing the form and not saving any changes rather than having to store
values, but I think I will have to do it your way.
Allen Browne wrote:
To achieve what you want, you would need to create a table to hold the
user's preferences for each field.

Presumably you will add a Save Layout button to the toolbar for the
datasheet form, so that clicking this button saves the Column Order and
ColumnWidth for each column, information about which columns are frozen,
etc.

Then in the Open event of the form, you read the values from the table, and
assign them to the various columns, which effectively restores the form to
the user's last *saved* settings, rather than Access's last saved settings
for the form.

Here's an example of how to set the properties of the columns in the Open
event of the form:

Private Sub Form_Open(Cancel As Integer)
Me.RowHeight = -1

With Me.ClientNum
.ColumnHidden = False
.ColumnOrder = 1
.ColumnWidth = 864
End With

With Me.Surname
.ColumnHidden = False
.ColumnOrder = 2
.ColumnWidth = 2880
End With

With Me.Address
.ColumnHidden = False
.ColumnOrder = 4
.ColumnWidth = -2 'Set for visible text.
End With

RunCommand acCmdUnfreezeAllColumns
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"deekay" <de*****@gmail.comwrote in message
news:11********************@h54g2000cwb.googlegrou ps.com...

deekay wrote:
I want to allow users to resize and reposition columns of a datasheet
but for a prompt to be brought up and only the layout only to be saved
if they select "save changes". This is the way it works at the moment
for queries but for datasheet forms I find that it automatically saves
column positions and widths without prompting to save changes.

I should mention i am using Access 2000
I noticed one of way of doing this is when the prompt "do you want to
save changes to the design of form xxxxx" is brought up, but this is
only brought up when altering a form in design view and not in
datasheet view. Still looking for a way
Nov 5 '06 #4
deekay wrote:
Thanks for the response I think this may the only way of doing it.
However what I would really like is something very simple like just
closing the form and not saving any changes rather than having to store
values, but I think I will have to do it your way.
My own experience in A97 and A2003 is that a datasheet, when a subform
of a main form, always retains its user settings. I always include a
pop up menu item to allow a user to have default widths, heights, plus
any frozen columns, restored.
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Nov 5 '06 #5
it's just a matter of how the main form is closed. i only allow my users to
close a form from a command button, which always includes the code

DoCmd.Close , , acSaveNo

subform column widths are not saved in this instance. changing the code to

DoCmd.Close

allows the default acSaveYes to apply, and subform column widths *are* saved
in this instance.

deekay, you can add a command button to your main form, and change the
form's ControlBox and CloseButton properties to No, so the user is forced to
close the form using the command button. then add an unbound checkbox to the
form so the user can checkmark the box when s/he wants to save his/her
current changes to the subform datasheet. add the following code to the
command button's Click event procedure, as

If Me!CheckboxName = True Then
DoCmd.Close
Else
DoCmd.Close , , acSaveNo
End If

replace CheckboxName with the correct name of the checkbox, of course.
recommend you precede the above code with an explicit save of the current
record, to make sure you don't lose any changes on Close, as

If Me.Dirty Then Me.Dirty = False

also, suggest you consider Tim's suggestion of a pop-up menu to restore
default settings; that's an excellent option that your users will be
grateful to have available to them.

hth
"Tim Marshall" <TI****@PurplePandaChasers.Moertheriumwrote in message
news:ei**********@coranto.ucs.mun.ca...
deekay wrote:
Thanks for the response I think this may the only way of doing it.
However what I would really like is something very simple like just
closing the form and not saving any changes rather than having to store
values, but I think I will have to do it your way.

My own experience in A97 and A2003 is that a datasheet, when a subform
of a main form, always retains its user settings. I always include a
pop up menu item to allow a user to have default widths, heights, plus
any frozen columns, restored.
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me

Nov 5 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Steve Sabljak | last post by:
I seem to having a little trouble getting a table to display correctly in both msie and firefox. I want to set the table and column widths in pixels, and have some cell padding too. The table...
1
by: Fred Ferreira | last post by:
Hi there Does anybody know how I can lock the column widths at Datasheet form view?
3
by: dhowell | last post by:
Can I have a datasheet form automatically "fit" the column widths when the form opens?
4
by: Rich | last post by:
Hello, I have a one datagrid that will be based on different datatables. One datatable may have 7 columns, another 15... With the tables that have more columns, I have been manually dragging...
4
by: Markus Ernst | last post by:
Hi Looking for a possibility to get separate tables rendered with common column widths, I was surprised to see that this code validates: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"...
0
by: deekay | last post by:
I want to allow users to resize and reposition columns of a datasheet but for a prompt to be brought up and only the layout only to be saved if they select "save changes". This is the way it works...
2
by: Midsomer | last post by:
Hi. I have an Access database with a form containing 4 datasheets and I allow the user to change column widths. On closing the form, a routine is fired that saves each column width to an INI file....
3
by: Simon Harvey | last post by:
Hi all, Can anyone tell me if there is an easy way to retain per-user column widths for the datagridview in a windows forms application. I know I could do it with a lot of database programming...
5
by: Deano | last post by:
I have five subforms each living in a page on a tab control. Each form is in datasheet view. The time has come to resize both the forms and the subforms. I am able to change the column widths...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.