Results 1 to 8 of 8
  1. #1
    tsgtnissen is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    28

    Textbox2 checks to see if it matches textbox1?

    Question: Is there a way to check if the value in textbox2 DOES NOT = textbox1 to make it do something like this:

    MsgBox ("The value you just entered does not match the original value. Would you still like to enter this value?", vbQuestion + vbYesNo) = vbYes Then

    "allow the value to be entered"

    Else

    "clear textbox2"






    ...and maybe as a bonus... if it matches perfectly it says something like
    MsgBox ("The value you just entered matches the original value."



    Once again thank you sooooo much!


    V/R
    Justin

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    Okay, you have the right idea with that code. Real question is what event should it go in - maybe Textbox2 BeforeUpdate? Something like:

    If Nz(Me.textbox2,"") <> Nz(Me.textbox1,"") Then
    If MsgBox("The value you just entered does not match the original value. Would you still like to enter this value?", vbQuestion + vbYesNo) = vbNo Then
    Cancel = True
    End If
    End If

    Suggest you forego the alternate message popup. I think user would just find it annoying.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    tsgtnissen is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    28
    The code you provided works, but I need help with one more thing. To ensure the value entered into .Basic_Amount & .Debit is always a negative number, I have this code in the afterupdate():

    Code:
    Private Sub Basic_Amount_AfterUpdate()Me.Basic_Amount = -1 * (Abs(Me.Basic_Amount))
    End Sub
    The crappy thing is every time a user enters a positive number your code runs before the number can be converted.

    Is there a way to work in the code above to make sure it converts the number first, then checks to see if the numbers match?


    Code:
    Private Sub Basic_Amount_BeforeUpdate(Cancel As Integer)If Nz(Me.Basic_Amount, "") <> Nz(Me.Debit, "") Then
    If MsgBox("The value you just entered does not match the original value. Would you still like to enter this value?", vbQuestion + vbYesNo) = vbNo Then
    Cancel = True
    End If
    End If
    End Sub

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    Maybe:

    If Abs(Nz(Me.Basic_Amount, 1)) * -1 <> Abs(Nz(Me.Debit, 1)) * -1 Then
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    tsgtnissen is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    28
    First, I would like to thank you for all the help you have already provided!

    Code:
    Private Sub Basic_Amount_BeforeUpdate(Cancel As Integer)
    If Abs(Nz(Me.Basic_Amount, 1)) * -1 <> Abs(Nz(Me.Debit, 1)) * -1 Then 'This is the code that will check the two text fields and see if they are the same. Then the afterupdate will ensure the output is a negitive number.
     If MsgBox("The value you just entered does not match the original value. Would you still like to enter this value?", vbQuestion + vbYesNo) = vbNo Then
        Cancel = True
    
        End If
     End If
    
    End Sub
    This is what I have so far...and it works.... there is only one last super small detail I need to adjust.

    Code:
     Then
        Cancel = True
    This does not clear the text box. It just closes the msgbox and prevents the afterupdate() code from running. This leaves me with whatever was typed in to the textfield.

    I have tried

    Code:
    me.Basic_Amount = ""
    and it does not work.

    My end goal is if they click "No" it clear the field of all data.


    V/R
    Justin

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    Try:

    Me.Basic_Amount = Null
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    tsgtnissen is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    28
    Nope still wont work. It just give me an error and highlights that code.

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    Sorry, I should have remembered that won't work.

    Reference control name (not field name) with Undo method.

    Me.Basic_Amount.Undo

    I name controls different from the fields they are bound to, like: tbxBasic
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. print bank checks
    By hlowmaster in forum Reports
    Replies: 1
    Last Post: 05-28-2014, 09:38 PM
  2. Replies: 19
    Last Post: 02-15-2014, 05:34 PM
  3. Inputing Checks
    By bornstein.a in forum Access
    Replies: 1
    Last Post: 08-27-2012, 04:29 PM
  4. Replies: 1
    Last Post: 12-19-2011, 12:16 PM
  5. check textbox1 on each record of report
    By sconard in forum Access
    Replies: 8
    Last Post: 04-13-2011, 12:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums