Solved

Exit back to a form if a selection is not made

Posted on 2014-10-10
2
85 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
ID: 40396858
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
ID: 40397112
Thank you

It worked for me.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
This article will show you how to use shortcut menus in the Access run-time environment.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

895 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

12 Experts available now in Live!

Get 1:1 Help Now