VB / Access code to compare textboxes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Robin Lewis

    VB / Access code to compare textboxes

    I have a simple Access database set up and a form and I need to compare two textboxes,
    'email1' and 'email2', on the form.

    If the two textboxes do NOT match I need to change the background colour of 'email1' to
    RED to bring this to my attention.

    This needs to change on a 'per record' basis, so as I scroll through the records using the
    standard 'next' and 'previous' buttons I can quickly see which ones are and are not
    matched!

    Can anyone submit some code for me as I have NO idea at all!

    PS this needs to work directly in Access and not a standalone VB frontend!


  • Steve Gerrard

    #2
    Re: VB / Access code to compare textboxes


    "Robin Lewis" <agent@blueyond er.co.uk> wrote in message
    news:l74s10hqo6 p1f09gn6924m997 9jigtmp31@4ax.c om...[color=blue]
    > I have a simple Access database set up and a form and I need to[/color]
    compare two textboxes,[color=blue]
    > 'email1' and 'email2', on the form.
    >
    > If the two textboxes do NOT match I need to change the background[/color]
    colour of 'email1' to[color=blue]
    > RED to bring this to my attention.
    >
    > This needs to change on a 'per record' basis, so as I scroll through[/color]
    the records using the[color=blue]
    > standard 'next' and 'previous' buttons I can quickly see which ones[/color]
    are and are not[color=blue]
    > matched!
    >
    > Can anyone submit some code for me as I have NO idea at all!
    >
    > PS this needs to work directly in Access and not a standalone VB[/color]
    frontend![color=blue]
    >
    >[/color]

    Form code in Access:

    Private Sub Form_Current()
    If Me.TestText1 <> Me.TestText2 Then
    Me.TestText1.Fo reColor = vbRed
    Else
    Me.TestText1.Fo reColor = vbBlack
    End If
    End Sub

    I set the text color; you can use .BackColor instead if you really want
    a red background.



    Comment

    • Rogier Bosch

      #3
      Re: VB / Access code to compare textboxes

      I've got one update on the procedure:

      Private Sub Form_Current()
      If Ucase(Me.TestTe xt1) <> Ucase(Me.TestTe xt2) Then
      Me.TestText1.Fo reColor = vbRed
      Else
      Me.TestText1.Fo reColor = vbBlack
      End If
      End Sub

      In original Rogierbosch@Me. com isn't the same as rogierbosch@me. com if you
      put everything in the uppercase (or lower) then you got a correct
      match....It's an option........




      "Steve Gerrard" <notstevegerrar d@comcast.net> schreef in bericht
      news:x8WdnZ_LgO 5mhIPd4p2dnA@co mcast.com...[color=blue]
      >
      > "Robin Lewis" <agent@blueyond er.co.uk> wrote in message
      > news:l74s10hqo6 p1f09gn6924m997 9jigtmp31@4ax.c om...[color=green]
      > > I have a simple Access database set up and a form and I need to[/color]
      > compare two textboxes,[color=green]
      > > 'email1' and 'email2', on the form.
      > >
      > > If the two textboxes do NOT match I need to change the background[/color]
      > colour of 'email1' to[color=green]
      > > RED to bring this to my attention.
      > >
      > > This needs to change on a 'per record' basis, so as I scroll through[/color]
      > the records using the[color=green]
      > > standard 'next' and 'previous' buttons I can quickly see which ones[/color]
      > are and are not[color=green]
      > > matched!
      > >
      > > Can anyone submit some code for me as I have NO idea at all!
      > >
      > > PS this needs to work directly in Access and not a standalone VB[/color]
      > frontend![color=green]
      > >
      > >[/color]
      >
      > Form code in Access:
      >
      > Private Sub Form_Current()
      > If Me.TestText1 <> Me.TestText2 Then
      > Me.TestText1.Fo reColor = vbRed
      > Else
      > Me.TestText1.Fo reColor = vbBlack
      > End If
      > End Sub
      >
      > I set the text color; you can use .BackColor instead if you really want
      > a red background.
      >
      >
      >[/color]


      Comment

      Working...