سلام
بهترین توصیه همون هست که جناب mazoolagh گفتند ولی برای وضعیت موجود از این کد میتونید استفاده بکنید:
Private Sub Command49_Click()
Dim TempLoginID
Dim sq As String
Dim rs As Recordset
If Len(Nz(Me!Text0, "")) = 0 Then
' Textbox UserName is empty
MsgBox "Please Enter Username ", vbInformation, "Provide Username"
Me.Text0.SetFocus
GoTo ExitPoint
End If
If Len(Nz(Me!Text3, "")) = 0 Then
' Password textbox is empty
MsgBox "Please Enter Password ", vbInformation, "Provide Password"
Me.Text3.SetFocus
GoTo ExitPoint
End If
sq = "select * from UserPass where UserName='" & Me.Text0 & "' and Password='" & Me.Text3 & "'"
Set rs = CurrentDb().OpenRecordset(sq, dbOpenForwardOnly, dbSeeChanges)
If rs.RecordCount = 0 Then
MsgBox ("Wrong Password. Try again!")
GoTo ExitPoint
Else
' TempVars!TempLoginID = Me.Text0
DoCmd.OpenForm "SelectOption", acNormal
DoCmd.Restore
End If
If Check53.Value = True Then
Dim Log, Pas, FormName As String
Log = Me.Text0
Pas = Me.Text3
FormName = "Login"
DoCmd.OpenForm FormName, acDesign, , , , acHidden
Forms(FormName)!Text0.DefaultValue = "'" & Log & "'"
Forms(FormName)!Text3.DefaultValue = "'" & Pas & "'"
DoCmd.Close acForm, FormName, acSaveYes
DoCmd.OpenForm FormName, acNormal, , , , acHidden
End If
ExitPoint:
Exit Sub
End Sub