已有23人关注
请教如何使报表数据来源于当前窗体
发表在VB答疑区 2008-04-16
是否精华
版块置顶:
<P>现出现了如下问题,点击打印按钮后,出现“未找到datafield'command1.badgeid'”,报表一片空白。我把我的代码抄录下来,您能帮我看看问题出在哪儿吗?</P>
<P>Private Sub DataList1_Click()<BR>&nbsp; If DataList1.BoundText = "" Then<BR>&nbsp;&nbsp;&nbsp; CurEmp.Init<BR>&nbsp;&nbsp;&nbsp; Image1.Picture = LoadPicture("")<BR>&nbsp;&nbsp;&nbsp; AdoEmpDetail.RecordSource = "SELECT * FROM Employees WHERE EmpId&lt;0"<BR>&nbsp;&nbsp;&nbsp; AdoEmpDetail.Refresh<BR>&nbsp;&nbsp;&nbsp; Exit Sub<BR>&nbsp; End If<BR>&nbsp; '根据选择的员工更新AdoEmpDetail<BR>&nbsp; AdoEmpDetail.RecordSource = "SELECT * FROM Employees " _<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + "WHERE EmpId=" + Trim(Str(DataList1.BoundText))<BR>&nbsp; AdoEmpDetail.Refresh<BR>&nbsp; '显示员工照片<BR>&nbsp; Call ShowImage(Image1, AdoEmpDetail)<BR>&nbsp; '读取当前员工信息到CurEmp<BR>&nbsp; CurEmp.GetInfo (DataList1.BoundText)<BR>&nbsp;End Sub<BR><FONT color=#ff3300>Private Sub Command1_Click()'打印按钮<BR>&nbsp; Set DataReport2.DataSource = AdoEmpDetail<BR>&nbsp; DataReport2.Sections("Command2_Detail").Controls("txt出入证号").DataField = "BadgeID"<BR>&nbsp; DataReport2.Sections("Command2_Detail").Controls("txt姓名").DataField = "EmpName"<BR>&nbsp; DataReport2.Sections("Command2_Detail").Controls("txt性别").DataField = "Sex"<BR>&nbsp; DataReport2.Sections("Command2_Detail").Controls("txt出生日期").DataField = "Birth"<BR>&nbsp; DataReport2.Sections("Command2_Detail").Controls("txt常住地址").DataField = "Files_Keep_Org"<BR>&nbsp; DataReport2.Sections("Command2_Detail").Controls("txt暂住地址").DataField = "Hukou"<BR>&nbsp; DataReport2.Sections("Command2_Detail").Controls("txt婚姻状况").DataField = "Marital_Condition"<BR>&nbsp; DataReport2.Sections("Command2_Detail").Controls("txt到岗日期").DataField = "HireDate"<BR>&nbsp; DataReport2.Sections("Command2_Detail").Controls("txt填表日期").DataField = "Fillin_Time"<BR>&nbsp; DataReport2.Sections("Command2_Detail").Controls("txt所属分厂").DataField = "DepId"<BR>&nbsp; DataReport2.Sections("Command2_Detail").Controls("txt工作岗位").DataField = "Position1"<BR>&nbsp; DataReport2.Sections("Command2_Detail").Controls("txt身份证号").DataField = "Id_Card"<BR>&nbsp; DataReport2.Sections("Command2_Detail").Controls("txt备注").DataField = "Memo1"<BR>&nbsp; MsgBox CurEmp.EmpName<BR>&nbsp; If FrmEmpMan.Image1.Picture &lt;&gt; 0 Then<BR>&nbsp; SavePicture FrmEmpMan.Image1.Picture, "temppic\mypicture.bmp"<BR>&nbsp; End If<BR>&nbsp; DataReport2.Show<BR>&nbsp; Const cf_bitmap = 2<BR>&nbsp; Dim msg<BR>&nbsp; On Error Resume Next<BR>&nbsp; Clipboard.Clear<BR>&nbsp; Clipboard.SetData LoadPicture("temppic\mypicture.bmp")<BR>&nbsp; If Err Then<BR>&nbsp;&nbsp;&nbsp;&nbsp; msg = "没有找到照片"<BR>&nbsp;&nbsp;&nbsp;&nbsp; MsgBox msg<BR>&nbsp;&nbsp;&nbsp;&nbsp; Exit Sub<BR>&nbsp; End If<BR>&nbsp;&nbsp;&nbsp;&nbsp; Set DataReport2.Sections("Command2_Detail").Controls("image1").Picture = Clipboard.GetData()<BR>&nbsp;&nbsp;&nbsp;&nbsp; DataReport2.Sections("Command2_Detail").Controls("image1").Picture = LoadPicture()<BR>End Sub<BR></FONT>Private Sub Form_Load()<BR>&nbsp; '设置ADO控件的连接字符串<BR>&nbsp; AdoEmpDetail.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + App.Path + "\人事.mdb;Persist Security Info=False"<BR>&nbsp; AdoEmpNameList.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + App.Path + "\人事.mdb;Persist Security Info=False"<BR>&nbsp; 'ComboState.ListIndex = 0<BR>&nbsp; FocusDepName = "劳动人事科"<BR>&nbsp; Focuskey = ""<BR>&nbsp; 'Root Node<BR>&nbsp; Set TmpNode = TreeView1.Nodes.Add(, , "a0", "部门信息", 1, 3)<BR>&nbsp; TmpNode.Selected = True<BR>&nbsp; TmpNode.ExpandedImage = 2<BR>&nbsp; '将部门信息添加到TreeView控件中<BR>&nbsp; Call Add_DepToTree(TreeView1, "a0")<BR>&nbsp; TreeView1_Click<BR>&nbsp; '如果不是管理员,则只显示员工姓名列表<BR>&nbsp; If CurUser.User_type &lt;&gt; 1 Then<BR>&nbsp;&nbsp;&nbsp; Frame1.Visible = False<BR>&nbsp;&nbsp;&nbsp; Frame2.Visible = False<BR>&nbsp;&nbsp;&nbsp; Cmd_Add.Visible = False<BR>&nbsp;&nbsp;&nbsp; Cmd_Modi.Visible = False<BR>&nbsp;&nbsp;&nbsp; Cmd_Del.Visible = False<BR>&nbsp;&nbsp;&nbsp; Cmd_Trans.Visible = False<BR>&nbsp;&nbsp;&nbsp; Me.Width = 2700<BR>&nbsp;&nbsp;&nbsp; Cmd_Back.Left = 600<BR>&nbsp; End If<BR>End Sub</P>
<P><BR>&nbsp;</P>
分享到:
精彩评论 1
vbsoldier
学分:0 LV1
2008-04-17
沙发
您好,请说明是哪本书的哪个例子。本例需要查看报表的设计样式才能够发现程序症结所在。
首页上一页 1 下一页尾页 1 条记录 1/1页
手机同步功能介绍
友情提示:以下图书配套资源能够实现手机同步功能
明日微信公众号
明日之星 明日之星编程特训营
客服热线(每日9:00-17:00)
400 675 1066
mingrisoft@mingrisoft.com
吉林省明日科技有限公司Copyright ©2007-2022,mingrisoft.com, All Rights Reserved长春市北湖科技开发区盛北大街3333号长春北湖科技园项目一期A10号楼四、五层
吉ICP备10002740号-2吉公网安备22010202000132经营性网站备案信息 营业执照