Solved

Exit back to a form if a selection is not made

Posted on 2014-10-10
2
88 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Lookup - Vlookup 9 43
vb.net deleting excel sheet in workbook 11 30
split data by day 21 29
Command button to lock and unlock sheet to protect formulas in Excel 6 21
Have you ever had the experience that you had to follow 10 steps over and over again every time when you need to nicely forward an important email to your manager? Fear no more! With the help of the Quick Steps feature in Outlook 2010, your old chor…
Outlook Free & Paid Tools
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…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

735 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