嵌套不对,改:
adodc2.CommandType = adCmdText
If Combo1.Text = "请选择" Then
MsgBox ("请选择!")
ElseIf Combo1.Text = "姓名" Then
adodc1.RecordSource = "select name,workno from works where name='" & Trim(Text2.Text) & "' "
adodc1.Refresh
Text1.Text = adodc1.Recordset.Fields(0)
a = adodc1.Recordset.Fields(1)
adodc2.RecordSource = "select workno,did,jb,jj,kouc,zuih=jb+jj-kouc from gongzi where workno='" & Trim(a) & "' "
adodc2.Refresh
If adodc2.Recordset.RecordCount > 0 Then
adodc2.Recordset.MoveFirst
For i = 0 To 5
If adodc2.Recordset.Fields(i) <> "" Then
Text(i).Text = adodc2.Recordset.Fields(i)
Else
Text(i).Text = ""
End If
Next i
end if
ElseIf Combo1.Text = "工作号" Then
adodc1.RecordSource = "select name from works where workno='" & Trim(Text2.Text) & "' "
adodc1.Refresh
Text1.Text = adodc1.Recordset.Fields(0)
adodc2.RecordSource = "select workno,did,jb,jj,kouc,zuih=jb+jj-kouc from gongzi where workno='" & Trim(Text2.Text) & "' "
adodc2.Refresh
If adodc2.Recordset.RecordCount > 0 Then
adodc2.Recordset.MoveFirst
For i = 0 To 5
If adodc2.Recordset.Fields(i) <> "" Then
Text(i).Text = adodc2.Recordset.Fields(i)
Else
Text(i).Text = ""
End If
Next i
End If
End If
镶嵌太多,可能不对称,建议改进程序
一层if end if就缩进 一点,这样才好检查
发代码的时候百度会屏蔽掉连续的空格的.
太乱.
标签:vb,else,语句