2.弹出窗体B,窗体B在加载事件执行 Me.PreFmName = Forms(Forms.Count - 2).Name ,使用文本框控件PreFmName获取窗体1的窗体名(呵呵,得到了t小宝版主的指点)复制代码
- Sub NewSql() '更新查询
- Dim VendorSql As String
- Dim frName As String
- frName = Me.Form.Name '获取当前窗体名
- '*开始输出SQL
- VendorSql = "SELECT [2_Vendor_Information].VendorNO, [2_Vendor_Information].VendorName, [2_Vendor_Information].VenAdress1, [2_Vendor_Information].VenAdress2,"
- VendorSql = VendorSql + "[2_Vendor_Information].Contact1, [2_Vendor_Information].Mobile1, [2_Vendor_Information].Contact2, [2_Vendor_Information].Mobile2,[2_Vendor_Information].Tel,"
- VendorSql = VendorSql + "[2_Vendor_Information].Fax, [2_Vendor_Information].Credit, [2_Vendor_Information].Checkout, [2_Vendor_Information].Email,[2_Vendor_Information].State"
- VendorSql = VendorSql + " FROM 2_Vendor_Information"
- VendorSql = VendorSql + " WHERE ((([2_Vendor_Information].VendorNO) Like" & Chr$(34) & "*" & Chr$(34)
- VendorSql = VendorSql + " & [Forms]!["
- VendorSql = VendorSql & frName
- VendorSql = VendorSql + "]![VendorNO] & " & Chr$(34) & "*" & Chr$(34)
- VendorSql = VendorSql + ")) OR ((([2_Vendor_Information].VendorName) Like" & Chr$(34) & "*" & Chr$(34)
- VendorSql = VendorSql + "& [Forms]!["
- VendorSql = VendorSql & frName
- VendorSql = VendorSql + "]![VendorNO] &" & Chr$(34) & "*" & Chr$(34)
- VendorSql = VendorSql + ")) ORDER BY [2_Vendor_Information].VendorNO;"
- Call UpSql("b_InQuiry_VendorQuery", VendorSql)
- End Sub
3.双击窗体B中的内容,将内容传送到窗体1.
复制代码
- Sub TranVendor()
- Dim fName As String
- fName = Me.Parent.PreFmName
- Forms(fName).[VendorNO] = Me.VendorNO
- DoCmd.Close
- End Sub
'------------------------------------------
上面的方法达到了我的要求,但是窗体1,窗体2,窗体3......都个窗体都要包含一个子程序"NewSql",感觉程序有些臃肿. 我觉得应该可以用模块来进行精简,但是小弟的access是边用边学,以前没接触过,对模块是一头雾水. 所以请大家帮一下忙,编一个模块,可以将"NewSql" 这个子程序精简到模块里.
附件在这里:[attach]47474[/attach]
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) | Powered by Discuz! X3.3 |