Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2002
    Location
    New Zealand
    Posts
    19

    Unanswered: Catch if Text box has changed on lose focus

    Hello,
    A fresh problem.
    I have two feilds, i.e text boxes which are password protected, or will be.
    What I was hoping was for if the feild was not changed no problem.
    If the feild value is changed a security password springs into life.
    After 4 attempts the form closes.
    Here is my attempt only it doesn't work. I can't get a validation for a change, I have tried [Exchange Rate].Dirty and [Exchange Rate]<> [Excahnge Rate]=Original.

    If Me![Exchange Rate] Then
    ' Display message box to inform the user that Management OK is needed for this price.
    strTitle = "Management OK is needed for This Change."
    strMsg = "Management Authority is Required for this Change" & vbNewLine & "Press Yes to Return Value To its Original." & vbNewLine & "Or No to Open Controls for Management to OK Change."
    If MsgBox(strMsg, vbQuestion + vbYesNo) = vbYes Then
    DoCmd.RunCommand acCmdUndo
    Exit Sub


    Else

    Dim Password As String, strinput As String, strPW2 As String, strMsg1 As String, strTitle1 As String, strMsg2 As String, strTitle2 As String
    strMsg1 = "Incorrect Password" & vbNewLine & "Please Try Again"
    strMsg2 = "That was your Fourth attempt!" & vbNewLine & "The form will now close!"
    strTitle1 = "Invalid Password"
    strTitle2 = "Fourth Attempt"
    Password = DLookup("Password", "Password")
    strPW2 = "wapfu"
    Do Until intCnt = 4 Or strinput = Password Or strinput = strPW2

    If intCnt = 4 Then
    MsgBox strMsg2, vbCritical + vbOKOnly, strTitle2
    DoCmd.Quit
    Exit Sub
    Else
    'do nothing
    End If
    strinput = InputBox("Enter Password")
    Select Case strinput

    Case Is = strPW2
    MsgBox "Entry was Successfull, Thankyou."
    Me![Special] = 1
    DoCmd.SAVE

    Exit Sub

    Case Is <> Password
    If MsgBox(strMsg1, vbCritical + vbYesNo, strTitle1) = vbYes Then
    intCnt = intCnt + 1
    Else
    Exit Sub
    End If

    Case Is = Password
    MsgBox "Entry was Successfull, Thankyou."
    Me![Special] = 1
    DoCmd.SAVE
    Exit Sub



    End Select
    Loop

    End If
    Else
    'do nothing
    Exit Sub
    End If

    Thanks to anyone in advance who can assist.
    Cheers
    regards
    bill

  2. #2
    Join Date
    Apr 2002
    Location
    Germany
    Posts
    228
    I would recommend to use the BeforeUpdate event. It appears after the user has entered new data into a contol but _before_ it is written to disc or he can leave the control. You can have your password checking code there and if it fails set the cancel parameter that is passed byref to true. This will result in the user not able to leave the control. Alternatively you could use the undo method of the control to change it back to the old value.

    Hope that's about what you wanted

    Michael

  3. #3
    Join Date
    Apr 2002
    Location
    New Zealand
    Posts
    19
    Thanks Apel,

  4. #4
    Join Date
    Feb 2002
    Posts
    2,232
    Why not use the keypress event of the text boxes ? - this would also give you control to prevent any entry in the text boxes unless authorized. As soon as something is attempted in one of the secured text boxes, use the keypress event and request the password - if successful change blnOKtoEdit to true and allow editing to continue else false and set keyascii to 0.

    Good luck.
    Last edited by rnealejr; 06-20-02 at 13:14.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •