Check the recordset value against the Form value. Use recordsetClone to obtain copy of recordset and Bookmark to move to the record number of that set on the form. If the values differ then show the message.
Private Sub Text2_LostFocus()
' check if form entry has occured
If Me.Dirty Then
curVal = Me!Text2 'Refer to name of control
'Set recordset to the same record
Set rst = Me.RecordsetClone
rst.Bookmark = Me.Bookmark
dbVal = rst.Field1 'Refer to name of Recordset field
' check if value has changed
If curVal <> dbVal Then
' Display message box
msg = "You have Entered: '" & curVal & "' on the Form"
If you have "Option Explicit" at the top of your module you have to Dimension (define) your variables, otherwise you'll get an error like the error you got. So either remove option explicit from your module and let access figure out the variable type (The lazy Way, like I did) Or Dim the variables at the top of your procedure.
Dim rst as Recordset
Dim curVal as String
Dim dbVal as String
May need to use (Dim rst as DAO.Recordset) if ADO library referenced.
Also you'll have to change the field names in the code to match the control / field names of your database.