Option Explicit
Private Sub Option1_Click()
   Option1.Value = True
End Sub
Private Sub Option2_Click()
   Option2.Value = True
End Sub
Private Sub Option3_Click()
   Option3.Value = True
End SubPrivate Sub Command1_Click()
    Form2.Show
    Me.Hide
End SubPrivate Sub Command2_Click()
     Dim 用户名 As String
   Dim 密码 As String
   Dim conn As New ADODB.Connection
   Dim rs As New ADODB.Recordset
   Dim StrSQL As String
   Dim bo As Boolean
   bo = False
   conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Administrator\桌面\教务\db1.mdb"
   用户名 = Trim(Text1.Text)
   密码 = Trim(Text2.Text)
   StrSQL = "select * from 用户 where 用户名= '" & 用户名 & "'and 密码 ='" & 密码 & "'"
   rs.Open StrSQL, conn, adOpenKeyset, adLockPessimistic
If 用户名 = "" Or 密码 = "" Then   MsgBox "对不起,用户或密码不能为空!请重新输入!"
Else
If rs.EOF = True Then
   MsgBox "对不起,无此用户或者密码不正确!请重新输入!"  
Else
   bo = True
End If
End If
      If bo = True Then
        If Option1.Value = True Then
         Form3.Show
         Form1.Hide
        ElseIf Option2.Value = True Then
         Form5.Show
         Form1.Hide
        Else: Option3.Value = True
         Form4.Show
         Form1.Hide
     End If
     End If
End SubPrivate Sub Command3_Click()
  Unload Me
End Sub

解决方案 »

  1.   

    我想把单选按钮和数据库连接起来如下面的你看对吗?Private Sub Option1_Click()
       StrSQL2 = "select 职业 from 用户,学生,教师,管理员 where 用户.用户名=学生用户名 and  用户.用户名=教师.用户名 and 用户.用户名=管理员.用户名"
        If StrSQL2 = Lable4.Caption Then
       Option1.Value = True
    End Sub
    Private Sub Option2_Click()
       StrSQL2 = "select 职业 from 用户,学生,教师,管理员 where 用户.用户名=学生用户名 and  用户.用户名=教师.用户名 and 用户.用户名=管理员.用户名"
       If StrSQL2 = Lable4.Caption Then
       Option2.Value = True
    End Sub
    Private Sub Option3_Click()
       StrSQL2 = "select 职业 from 用户,学生,教师,管理员 where 用户.用户名=学生用户名 and  用户.用户名=教师.用户名 and 用户.用户名=管理员.用户名"
       If StrSQL2 = Lable5.Caption Then
       Option3.Value = True
    End Sub
      

  2.   

    http://hi.csdn.net/space-4023163-do-album-picid-456387.html这个网址有个界面图片(我的空间)就是上面的要求