<P>谢谢您的回复。我照您的办法改写了代码,但我基础较弱,可能没完全理解您的意思。现出现了如下问题,点击打印按钮后,出现“未找到datafield'command1.badgeid'”,报表一片空白。我把我的代码抄录下来,您能帮我看看问题出在哪儿吗?</P>
<P>Private Sub DataList1_Click()<BR> If DataList1.BoundText = "" Then<BR> CurEmp.Init<BR> Image1.Picture = LoadPicture("")<BR> AdoEmpDetail.RecordSource = "SELECT * FROM Employees WHERE EmpId<0"<BR> AdoEmpDetail.Refresh<BR> Exit Sub<BR> End If<BR> '根据选择的员工更新AdoEmpDetail<BR> AdoEmpDetail.RecordSource = "SELECT * FROM Employees " _<BR> + "WHERE EmpId=" + Trim(Str(DataList1.BoundText))<BR> AdoEmpDetail.Refresh<BR> '显示员工照片<BR> Call ShowImage(Image1, AdoEmpDetail)<BR> '读取当前员工信息到CurEmp<BR> CurEmp.GetInfo (DataList1.BoundText)<BR> End Sub<BR><FONT color=#ee1111>Private Sub Command1_Click()'打印按钮<BR> Set DataReport2.DataSource = AdoEmpDetail<BR> DataReport2.Sections("Command2_Detail").Controls("txt出入证号").DataField = "BadgeID"<BR> DataReport2.Sections("Command2_Detail").Controls("txt姓名").DataField = "EmpName"<BR> DataReport2.Sections("Command2_Detail").Controls("txt性别").DataField = "Sex"<BR> DataReport2.Sections("Command2_Detail").Controls("txt出生日期").DataField = "Birth"<BR> DataReport2.Sections("Command2_Detail").Controls("txt常住地址").DataField = "Files_Keep_Org"<BR> DataReport2.Sections("Command2_Detail").Controls("txt暂住地址").DataField = "Hukou"<BR> DataReport2.Sections("Command2_Detail").Controls("txt婚姻状况").DataField = "Marital_Condition"<BR> DataReport2.Sections("Command2_Detail").Controls("txt到岗日期").DataField = "HireDate"<BR> DataReport2.Sections("Command2_Detail").Controls("txt填表日期").DataField = "Fillin_Time"<BR> DataReport2.Sections("Command2_Detail").Controls("txt所属分厂").DataField = "DepId"<BR> DataReport2.Sections("Command2_Detail").Controls("txt工作岗位").DataField = "Position1"<BR> DataReport2.Sections("Command2_Detail").Controls("txt身份证号").DataField = "Id_Card"<BR> DataReport2.Sections("Command2_Detail").Controls("txt备注").DataField = "Memo1"<BR> MsgBox CurEmp.EmpName<BR> If FrmEmpMan.Image1.Picture <> 0 Then<BR> SavePicture FrmEmpMan.Image1.Picture, "temppic\mypicture.bmp"<BR> End If<BR> DataReport2.Show<BR> Const cf_bitmap = 2<BR> Dim msg<BR> On Error Resume Next<BR> Clipboard.Clear<BR> Clipboard.SetData LoadPicture("temppic\mypicture.bmp")<BR> If Err Then<BR> msg = "没有找到照片"<BR> MsgBox msg<BR> Exit Sub<BR> End If<BR> Set DataReport2.Sections("Command2_Detail").Controls("image1").Picture = Clipboard.GetData()<BR> DataReport2.Sections("Command2_Detail").Controls("image1").Picture = LoadPicture()<BR>End Sub<BR></FONT>Private Sub Form_Load()<BR> '设置ADO控件的连接字符串<BR> AdoEmpDetail.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _<BR> + App.Path + "\人事.mdb;Persist Security Info=False"<BR> AdoEmpNameList.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _<BR> + App.Path + "\人事.mdb;Persist Security Info=False"<BR> 'ComboState.ListIndex = 0<BR> FocusDepName = "劳动人事科"<BR> Focuskey = ""<BR> 'Root Node<BR> Set TmpNode = TreeView1.Nodes.Add(, , "a0", "部门信息", 1, 3)<BR> TmpNode.Selected = True<BR> TmpNode.ExpandedImage = 2<BR> '将部门信息添加到TreeView控件中<BR> Call Add_DepToTree(TreeView1, "a0")<BR> TreeView1_Click<BR> '如果不是管理员,则只显示员工姓名列表<BR> If CurUser.User_type <> 1 Then<BR> Frame1.Visible = False<BR> Frame2.Visible = False<BR> Cmd_Add.Visible = False<BR> Cmd_Modi.Visible = False<BR> Cmd_Del.Visible = False<BR> Cmd_Trans.Visible = False<BR> Me.Width = 2700<BR> Cmd_Back.Left = 600<BR> End If<BR>End Sub<BR></P>
<P> </P>