Dim cnn As DAO.Database
Dim rst As DAO.Recordset
Private Sub Command1_Click()
Dim bas As Variant
Set rst = cnn.OpenRecordset("select * from 系統用戶")
rst.FindFirst "[用戶]='" & Me.Text1.Text & "' and [密碼]='" & IIf(Me.Text2.Text = "", "z", Me.Text2.Text) & "'"
If LCase(rst!用戶) = LCase(Me.Text1.Text) And rst!密碼 = IIf(Me.Text2.Text = "", "z", Me.Text2.Text) Then
Me.Visible = False
If Dir("I:\系統\" & Me.Text1.Text & ".txt") = "" Then GoTo RunA
fil.DeleteFile "I:\" & Me.Text1.Text & ".txt"
RunA:
Dim strDB As String
Dim strCmd As String
strDB = "C:\Molding.mde"
rst.FindFirst "[用戶]='a'"
bas = rst!密碼
End
Exit Sub
Else
MsgBox "密碼錯誤", vbCritical, "密碼"
End If
rst.Close
Set rst = Nothing
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
DBEngine.DefaultUser = "系統用戶"
DBEngine.DefaultPassword = ""
DBEngine.SystemDB = "I:\Short\kmq013.mdw"
Set cnn = DBEngine.OpenDatabase("I:\molding.mde")
Set rst = cnn.OpenRecordset("select * from 系統用戶")
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then Me.Command1.SetFocus
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then Me.Text2.SetFocus
End Sub