Private Sub Cmd_login_Click() Dim area As TextBox 'IDを格納 Dim pass As TextBox 'パスワードを格納 Dim strTBL As Variant ’テーブル名を格納 Dim cn As ADODB.Connection Dim rs As ADODB.Recordset Dim SQL1 As Variant ’エリアコードSQL文 Dim SQL2 As Variant ’パスワードSQL文 Set area = Me.Text_area Set pass = Me.Text_pass Set cn = New ADODB.Connection Set rs = New ADODB.Recordset strTBL = "login" 'テーブル名 'Mysqlへ接続 cn.Open "Driver={MySQL ODBC 3.51 Driver};SERVER = ●●●●;DATABASE=testdb;UID=suzuki;PWD=1234;STMT=SET CHARACTER SET cp932; " 'テーブルを開く rs.Open strTBL, cn, adOpenForwardOnly, adLockOptimistic, adCmdTable SQL1 = "SELECT * FROM login WHERE F_area" 'loginテーブルF_areaフィールド SQL2 = "SELECT * FROM login WHERE F_pass" 'loginテーブルF_passフィールド If area = SQL1 Then If pass = SQL2 Then 'ID・PASSが一致したらメイン画面が開く f_main.Show Me.Hide Else End If Set cn = Nothing Set rs = Nothing End Sub