在MS-Access中设置和保留“拆分表格"数据表列的列宽 [英] Set and retain column widths of Split Form datasheet columns in MS-Access

查看:89
本文介绍了在MS-Access中设置和保留“拆分表格"数据表列的列宽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Access 2012中使用的是Split Form.顶部的基本数据表视图在底部的窗格中具有单独的记录和表单头.

I'm using a Split Form in Access 2012. Basic datasheet view on top with individual record and form header in bottom pane.

我正在尝试确定是否有一种方法可以将列宽保持为手动设置的宽度-理想情况下,加载窗体时,可以通过VBA代码将列宽设置为BestFit.

I'm trying to figure if there's a way to keep my column widths to manually sized widths - and ideally, set column widths to BestFit via VBA code when the Form loads.

我发现了这一个hack 下次启动时列的宽度.

I have found this one hack that remembers the column widths the next time you start.

我遇到了同样的问题.对我有用的内容(访问2010年拆分表格) 是要调整所有列的大小(通过拖动 列标题)的方式,然后右键单击任何列标题 并选择隐藏列".隐藏任何列,单击确定",然后右键单击 再次在任何列上,选择取消隐藏列",然后取消隐藏您隐藏的列 首先.单击确定",然后将打开带有以下内容的表格: 每次都调整列宽的大小.

I had the same problem. What worked for me (Access 2010 Split Form) was to resize all the columns (by dragging the right edge of the column header) the way I wanted, then right click any column header and select "Hide Column." Hide any column, click "Ok" then right click again on any column, choose "Unhide Column" and unhide the one you hid in the first place. Click "Ok" and presto the form opens with the resized column widths every time.

但是如果我分发数据库,​​问题再次发生.

But the problem happens again if I distribute the database.

如果我能以某种方式引用数据表视图列对象,则可能可以应用BestFit方法

If I could somehow reference the datasheet view columns object, I could probably apply the BestFit method

编辑-更新:我尝试使用此功能无效:

For Each ctl In Me.Controls
   With ctl 
      Select Case .ControlType
         Case acTextBox
            Debug.Print .Name
            If Not .ColumnHidden Then
               .ColumnWidth = -2
            End If
      End Select
  End With
Next

推荐答案

不幸的是,"Me.[Field1] .ColumnWidth = -2"不适用于拆分视图.

这一系列奇怪的步骤似乎是在MS Access(2007-2013)拆分表格"中保存列宽的唯一方法:

Unfortunately, "Me.[Field1].ColumnWidth = -2" does not work for split view.

This bizarre series of steps appears to be the only way to save column widths in an MS Access (2007-2013) "split form":

  1. 在拆分视图中,在表单的数据表侧设置列宽.如果要将其设置为当前 最佳拟合,请双击任意列的右侧(不幸的是,即使最佳拟合"也将保存为静态宽度)
  2. 突出显示您要保存的宽度的列.如果要全部执行,请不要使用全选;选择第一个列标题,然后按住Shift键并单击最后一个列标题.
  3. 右键单击任何突出显示的列标题的中心,然后单击"隐藏字段" .您的所有列都应该消失.不用担心,这应该会发生.
  4. 在主菜单标签下,点击更多>取消隐藏字段,然后选择所有列.
  5. 点击 Save ,然后进入设计"视图,然后再次点击 Save .您的列宽将被保存.
  1. In split view, set your columns widths on the datasheet side of the form. Double-click on the right edge of any column if you want to set it to the current Best Fit (unfortunately even "Best Fit" will be saved as a static width).
  2. Highlight the columns with widths you want to save. If you are doing all of them, do not use Select-All; select the first column header, then shift-click on the last column header.
  3. Right-click on the center of any highlighted column header, then click Hide Fields. All of your columns should disappear. Don't worry, this is supposed to happen.
  4. Under the Home menu tab, click on More > Unhide Fields, and select all of the columns.
  5. Hit Save, then go into Design view, and hit Save again. Your column widths will be saved.

这篇关于在MS-Access中设置和保留“拆分表格"数据表列的列宽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆