Access交流中心

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

关于追加查询的问题

子煜  发表于:2010-07-10 18:46:27  
复制

详细见附档

 

点击下载此附件

 

Top
煮江品茶 发表于:2010-07-10 20:36:09

Private Sub Command2_Click()
Dim frm As Form
Dim ctls As Controls
Dim i As Long
Set frm = Me.条件查询入库明细子窗体.Form
Set ctls = frm.Controls
For i = 1 To frm.RecordsetClone.RecordCount
    frm.SelTop = i
    ctls("P_Select").Value = -1
Next
End Sub

Private Sub Command3_Click()
Dim frm As Form
Dim ctls As Controls
Dim i As Long
Set frm = Me.条件查询入库明细子窗体.Form
Set ctls = frm.Controls
For i = 1 To frm.RecordsetClone.RecordCount
    frm.SelTop = i
    ctls("P_Select").Value = 0
Next
End Sub

 

查询字段太多了,看着眼花,不想搞了。



子煜 发表于:2010-07-10 21:43:37
多谢,主要是追加查询不知道如何搞?

煮江品茶 发表于:2010-07-11 07:37:30

追加问题解决方案:

 

Private Sub Command4_Click()
Dim frm1 As Form
Dim ctls1 As Controls
Dim ctl1 As Control
Dim frm2 As Form
Dim ctls2 As Controls
Dim i As Long, j As Long
Set frm1 = Me.条件查询入库明细子窗体.Form
Set ctls1 = frm1.Controls
Set frm2 = Forms("出库主窗体").Controls("F_ProIn2").Form
Set ctls2 = frm2.Controls
For i = 1 To frm1.RecordsetClone.RecordCount
    frm1.SelTop = i
    If ctls1("P_Select") = True Then
        Forms("出库主窗体").Form.SetFocus
        Forms("出库主窗体").Controls("F_ProIn2").SetFocus
        If Nz(ctls2("P_ID").Value, 0) <> 0 Then
            DoCmd.RunCommand acCmdRecordsGoToNew
        End If
        For Each ctl1 In ctls1
            If ctl1.ControlType <> acLabel Then
                If ctlEx(frm2, ctl1.Name) = True Then
                    ctls2(ctl1.Name).Value = ctl1.Value
                End If
            End If
        Next ctl1
    End If
Next
frm1.Requery
frm2.Requery
End Sub

Function ctlEx(frm As Form, ctlname As String) As Boolean
Dim ctls As Controls
Dim ctl As Control
Set ctls = frm.Controls
ctlEx = False
For Each ctl In ctls
    If ctl.Name = ctlname Then
        ctlEx = True
        Exit For
    End If
Next ctl
End Function


 

点击下载此附件

煮江品茶 发表于:2010-07-11 09:49:44


子煜 发表于:2010-07-24 23:22:56
老师能否将VBA代码全部给注释一下,我看不懂,谢谢了。

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