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
|
|||
|
|||
Message Box
I have two fields in the form I want both of them to have the same equal data of tele each other and if the data is not same then display me a message. Note both fields are TEXT fields
|
#2
|
|||
|
|||
Message Box
Greetings Daud
This is a bit technical, so take your time... 1. Create a "PublicVariables" Module, and add the following: - Public Field1Blank,Field2Blank As Boolean Public String1,String2 As String Public MaxError As Integer Public MsgValue Save and close the Module For each fields "On Exit" Procedure, add the following... Field 1: - If Me.Field1 = "" Then Field1Blank = True Else Field1Blank = False Call CompareFields Field 2: - If Me.Field2 = "" Then Field2Blank = True Else Field2Blank = False Call CompareFields Create another Module "FormFunctions" and add the following: - Function CompareFields() On Error Goto CompareErr If Field1Blank=True Then Exit Function If Field2Blank=True Then Exit Function String1 = Forms![FormID]![Field1] String2 = Forms![FormID]![Field2] MaxError = StrComp (Field1,Field2,vbTextCompare) If MaxError 0 Then Exit Function MsgValue = MsgBox ("PUT MESSAGE HERE",vbOkCancel+vbExclamation) Forms![FormID]![Field1].SetFocus Exit Function CompareErr: msgbox (err.number & ", " & err.description) End Function Save the module, compile the VBA Project then close. Edit the programmes to reference the correct Form Name and Field Names. HTH Tony C. -----Original Message----- I have two fields in the form I want both of them to have the same equal data of tele each other and if the data is not same then display me a message. Note both fields are TEXT fields . |
Thread Tools | |
Display Modes | |
|
|