Solved

Exit back to a form if a selection is not made

Posted on 2014-10-10
2
83 Views
Last Modified: 2014-10-22
I want to write an If clause that will exit back to a Form if a condition is met.

Here is what I have:

If [Forms]![frm_Date_Selection]![Frame166].Value = 5 Then
    MsgBox "Please Select Report to Run."
    End Sub
End If
If [Forms]![frm_Date_Selection]![Frame137].Value = 13 Then
    MsgBox "Please Select From Month."
    End Sub
End If
If [Forms]![frm_Date_Selection]![List120].Value Is Null Then
    MsgBox "Please Select From Date."
    End Sub
End If

Open in new window


Can you help me out?

Thanks

Glen
0
Comment
Question by:GPSPOW
2 Comments
 
LVL 31

Accepted Solution

by:
Helen_Feddema earned 500 total points
Comment Utility
First, give the frame a meaningful name, to make your code more comprehensible.  Next, set up a Select Case statement to deal with the possible values.  For exiting to a form, do you mean to cancel another action and return to the calling form, or opening another form?

Here is some sample code for dealing with choices in an option group:

Private Sub cmdMultipleContactsQuery_Click()
'Created by Helen Feddema 28-May-2014
'Last modified by Helen Feddema 30-May-2014

On Error GoTo ErrorHandler
   
   intMethod = Nz(Me![fraMethodQuery].Value, 1)
   
   Select Case intMethod
   
      Case 1
         DoCmd.OpenForm FormName:="frmDocPropsQuery"
         
      Case 3
         DoCmd.OpenForm FormName:="frmTypeTextQuery"
      
      Case 2
         DoCmd.OpenForm FormName:="frmMailMergeQuery"
      
      Case 4
         DoCmd.OpenForm FormName:="frmBookmarksQuery"
         
      Case 5
         DoCmd.OpenForm FormName:="frmCatalogMergeQuery"
         
      Case 6
         DoCmd.OpenForm FormName:="frmFormFieldsQuery"
            
      Case 7
         DoCmd.OpenForm FormName:="frmDocVarsQuery"
            
   End Select
   
   Parent.Visible = False
   
ErrorHandlerExit:
   Exit Sub

ErrorHandler:
   MsgBox "Error No: " & Err.Number _
      & " in " & Me.ActiveControl.Name & " procedure; " _
      & "Description: " & Err.Description
   Resume ErrorHandlerExit

End Sub

Open in new window

0
 

Author Closing Comment

by:GPSPOW
Comment Utility
Thank you

It worked for me.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now