If and THEN help please

AndyShuter

Registered User.
Local time
Today, 13:42
Joined
Mar 3, 2003
Messages
151
Does anyone know how I would use IF and THEN in Code to perform a conditional action.

For example I have a text box which is in view, and a text box which is hidden.

The text box you can see (Box A) is an input required from the user. The text box you can't see (Box B) is an algorythm based on an underlying query that changes every day. (Therefore I will already knowthe future values of this field as the date changes!)

What I would like to do is say that if Box A is equal to Box B, Go to frmintro.

If Box A <> to Box B, exit.

The guy using the database will have to ring me everyday for the passcode or else he won't be able to get in.

Any suggestions please???
 
Andy,

Put this code in the AfterUpdate event of Box A:

Code:
If Me.[Box A] = Me.[Box B] Then
   DoCmd.OpenForm "frmintro"
Else
   DoCmd.Quit
End If

BoxA (without the spaces) is better and less confusing.

Wayne
 
You could try...

Dim A As String
Dim B As String

A = Me.Text2
B = Me.Text4

If A = B Then
DoCmd.OpenForm frmintro, acNormal, , , , acDialog
Else
MsgBox "YOUR MESSAGE HERE", vbOKOnly
DoCmd.Quit
End Sub


Just be sure to add the proper text field names instead of Text2 and Text4
There may be other items to account for, such as blanks that you may want to think about.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom