Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2011
    Posts
    1

    Unanswered: Using IF function on Access 2007 Form

    I do not know how to write codes.

    I have two dropdown fields on a form named [Outcome] and [RemandReason]. What I want to accomplish is: If "Remand/Reversed" is selected from the [Outcome] dropdown field, the user will be forced to select the Reason for the remand/reversal from the [RemandReason] field.

    In other words, if the selection in the [outcome] field says "Remand/Reversed", the [RemandReason] cannot be null. Otherwise, a message will be displayed informing the user that a Remand Reason is required.

    Your help with the code would be greatly appreciated.

    Thanks.

    Jideogu

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    I would use the before update event of the form:

    Before update

    You would first test the outcome field and then the reason field if appropriate.
    Paul

  3. #3
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Along the same line as Paul has suggested
    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
     If Me.Outcome = "Remand/Reversed" Then
      If Nz(Me.RemandReason, "") = "" Then
       Cancel = True
       MsgBox "If Outcome is Remand/Reversed, You Must Select a Remand Reason!"
       RemandReason.SetFocus
       Exit Sub
      End If
     End If
    End Sub
    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •