Text box Input

gselliott

Registered User.
Local time
Today, 05:43
Joined
May 17, 2002
Messages
106
I have got a Text box on a form that is used to enter in the record possition this will be used to sort the data and used in an Export.

What I want to be able to do is to stop the users from entering the same number twice e.g if they enter 10 into the first field and try to enter 10 into another field a message box will pop up and not accept the second attempt.

Thanks
 
gselliott said:
What I want to be able to do is to stop the users from entering the same number twice e.g if they enter 10 into the first field and try to enter 10 into another field a message box will pop up and not accept the second attempt.

That sounds like you have a repeating group in your table structure.

If you don't want to normalise your database (very much advised, though) then you can use the BeforeUpdate() event of the textbox's.

Do you want the message box to pop up immediately or when someone tries to close the form?

If the former: you'll need to do code for the BeforeUpdate() event of the controls

If the latterL you'll need to do code for the BeforeUpdate() event of the form
 
Yes I would like the message box to appear immediately.

Thanks for your reply.
 
Code:
Private Sub MyTextbox2_BeforeUpdate(Cancel As Integer)
    If Me.MyTextBox1 = Me.MyTextBox2 Then
        MsgBox "Textboxes can't be same number.", vbExclamation
        Me.MyTextBox2.Undo
        Cancel = True
    End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom