If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Detecting text entered in a text field
Is there a method or property to check if text has been entered in a
text field on a form? The way I have my form set up is if a user enters data in the text field and closes the form, the data gets stored in the table. Problem is, if the user enters existing data and closes the form, they are not prompted that the value already exists in the table. However, there's no redundant data in the table - when an existing value is entered and the form's closed, nothing's happening. I want to be able to prompt the user on typing text in the field and tabbing over to the next field, i.e. the moment he/she moves to another field or control on the form, they should get a warning. I can't use DCount or DLookup because i'm using a continuous form - existing values fill up that text field which appear one below the other. The bottom most field is blank for data entry. |
#2
|
|||
|
|||
"Shaldaman" wrote in message
ups.com Is there a method or property to check if text has been entered in a text field on a form? The way I have my form set up is if a user enters data in the text field and closes the form, the data gets stored in the table. Problem is, if the user enters existing data and closes the form, they are not prompted that the value already exists in the table. However, there's no redundant data in the table - when an existing value is entered and the form's closed, nothing's happening. I want to be able to prompt the user on typing text in the field and tabbing over to the next field, i.e. the moment he/she moves to another field or control on the form, they should get a warning. I can't use DCount or DLookup because i'm using a continuous form - existing values fill up that text field which appear one below the other. The bottom most field is blank for data entry. The text box's BeforeUpdate and AfterUpdate events will fire when the user enters anything in it and moves the focus off the control. You should be able to use one of those events to check if this value already exists in the table. I'm not sure why you say, "I can't use DCount or DLookup because i'm using a continuous form." I'd expect something like this to work: '---- start of example code ---- Private Sub YourField_BeforeUpdate(Cancel As Integer) If Not IsNull(YourField) Then If Not IsNull(DLookup("YourField", "YourTable", _ "YourField=" & Chr(34) & Me!YourField & Chr(34))) _ Then MsgBox "This value is already in the table. Try another value." Cancel = True End If End If End Sub '---- end of example code ---- -- Dirk Goldgar, MS Access MVP www.datagnostics.com (please reply to the newsgroup) |
#3
|
|||
|
|||
Thanks a lot. That worked. I appreciate it...
|
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
pass a calculated form field to a subform field? | Brook | Using Forms | 22 | April 28th, 2005 04:56 PM |
Combo Box (1st) Populating Text Box (2nd) Field | AccessRookie | Using Forms | 1 | April 6th, 2005 11:37 PM |
Syntax needed to get needed reports | Frank Lueder | New Users | 15 | January 6th, 2005 08:39 AM |
Outline | Renee Hendershott | Page Layout | 2 | December 25th, 2004 02:49 PM |
Text Form Field Ref in Footer Won't Update on Screen | StarWine | General Discussion | 3 | December 6th, 2004 06:17 PM |