A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Message Box



 
 
Thread Tools Display Modes
  #1  
Old June 4th, 2004, 08:51 AM
Daud Akbar
external usenet poster
 
Posts: n/a
Default 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  
Old June 4th, 2004, 09:56 AM
Tony C
external usenet poster
 
Posts: n/a
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:11 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.