Access交流中心

北京 | 上海 | 天津 | 重庆 | 广州 | 深圳 | 珠海 | 汕头 | 佛山 | 中山 | 东莞 | 南京 | 苏州 | 无锡 | 常州 | 南通 | 扬州 | 徐州 | 杭州 | 温州 | 宁波 | 台州 | 福州 | 厦门 | 泉州 | 龙岩 | 合肥 | 芜湖 | 成都 | 遂宁 | 长沙 | 株洲 | 湘潭 | 武汉 | 南昌 | 济南 | 青岛 | 烟台 | 潍坊 | 淄博 | 济宁 | 太原 | 郑州 | 石家庄 | 保定 | 唐山 | 西安 | 大连 | 沈阳 | 长春 | 昆明 | 兰州 | 哈尔滨 | 佳木斯 | 南宁 | 桂林 | 海口 | 贵阳 | 西宁 | 乌鲁木齐 | 包头 |

选中复制

良子  发表于:2012-09-02 19:33:59  
复制

我在主窗体上有两个子窗体分别是A和B 我想将A窗体上鼠标选中的一行或多行数据复制到B窗体上,请问用代码怎样实现。

 

Top
宏鹏 发表于:2012-09-03 13:13:42
良子 发表于:2012-09-03 19:06:30

我看到这个程序了,可是复制过来不好使,我的代码如下:

Dim i As Long, j As Long
Dim ctls As Controls, ctl As Control
Set ctls = Me.Child2.Form.Controls
Dim MyTop As Long, MyHeight As Long
MyTop = Me.查询7.Form.SelTop
MyHeight = Me.查询7.Form.SelHeight
Me.Child2.SetFocus
For i = 0 To MyHeight - 1 ' 选定的行数
    Me.查询7.Form.SelTop = MyTop + i
    If Me.Child2.Form.NewRecord <> True Then
        DoCmd.RunCommand acCmdRecordsGoToNew '增加一条记录
    End If
      For Each ctl In ctls
        If ctl.ControlType <> acLabel Then
            ctl.Value = Me.查询7.Form.Controls(ctl.name).Value
        
        End If
    Next ctl
    Me.Child2.Form.Recalc
Next

其中Dim i As Long, j As Long
Dim ctls As Controls, ctl As Control
Set ctls = Me.Child2.Form.Controls
Dim MyTop As Long, MyHeight As Long
MyTop = Me.查询7.Form.SelTop
MyHeight = Me.查询7.Form.SelHeight
Me.Child2.SetFocus
For i = 0 To MyHeight - 1 ' 选定的行数
    Me.查询7.Form.SelTop = MyTop + i
    If Me.Child2.Form.NewRecord <> True Then
        DoCmd.RunCommand acCmdRecordsGoToNew '增加一条记录
    End If
      For Each ctl In ctls
        If ctl.ControlType <> acLabel Then
            ctl.Value = Me.查询7.Form.Controls(ctl.name).Value
        
        End If
    Next ctl
    Me.Child2.Form.Recalc
Next

其中 MyHeight = Me.查询7.Form.SelHeight
SelHeight的值一直是0 为什么。




总记录:2篇  页次:1/1 9 1 :