是From不是Form,关键词拼写错误。
Private Sub Command2_Click()
On Error GoTo xerr
Dim xh As String
Dim xm As String
If Option1.Value = True Then
xh = Text1.Text
Adodc1.RecordSource = "select * from 学生信息 where 学生姓名='" & xh & "'"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
ElseIf Option2.Value = True Then
xm = Text1.Text
Adodc1.RecordSource = "select * from 学生信息 where 课程名='" & xm & "'"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
End If
Exit Sub
xerr:
MsgBox Err.Description, vbInformation, "提示"
End Sub
select * form 改成 select * from
from拼错了