VB中为找到未找到方法或数据成员

来源:百度知道 编辑:UC知道 时间:2024/05/10 06:01:53
Dim flag As Integer
Private Sub cxchenggong()
DataGrid2.Visible = True
Label2.Visible = True

If flag = 1 Then Adodc2.RecordSource = " select * from 职工工资结算表 where 员工编号='" & Text1.Text & "'"
If flag = 2 Then Adodc2.RecordSource = " select * from 职工工资结算表 where 员工姓名='" & Text2.Text & "'"
If flag = 3 Then Adodc2.RecordSource = " select * from 职工工资结算表 where 员工编号='" & Text1.Text & "' and 员工姓名='" & Text2.Text & "'"
Adodc2.Refresh

End Sub
Private Sub Command1_Click()
On Error GoTo chaxunerr
DataGrid1.Height = 700
DataGrid1.Top = 480
Dim i
i = 0
flag = 0 '1表示只使用编号查询,2表示只使用姓名查询,3表示使用编号和姓名组合查询
If Text1.Text <> "" And Text2.Text = "" Then
'员工编号查询
Adodc1.Recordset.MoveFirst
Do While Adodc1.Recordset.EOF <> True
If Text1.Text = Adodc1.Recordset.

报错在哪一行?是这句吧?

Adodc1.Recordset.MoveFirst

你把它注释了应该就对了
估计你form激活的时候还没有定义adodc对象

数据库连上了吗?

改成Private Sub Form_Load() 试试