Solved

Microsoft, Access, 2007, Call sub without return

Posted on 2008-10-07
2
723 Views
Last Modified: 2013-11-28
Hi

I have an if statement where, if something is true, a sub procedure is called which performs various operations and then closes the current form.  I don't want to return to the orginal procedure once the sub has been completed.  If I use Call, it returns.  How do I tell Access to go to a sub procedure and not return?  I have an idea I might need to use Function, but I don't know how to so, if that's the correct way of doing it, please could someone tell me how to use it?  If not, please could tell me someone how I call a sub without returning?

Thanks
Sarah
0
Comment
Question by:ScuzzyJo
2 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 500 total points
ID: 22657752
You cannot do so.
A procedure - whether a sub or a function- is defined as a 'temporary branch' from the current flow and will always return to the originating code.

If you want to close the form after the procedure has run then you should put the close form command immediately after the call to the sub/function in the calling procedure.
0
 

Author Closing Comment

by:ScuzzyJo
ID: 31503754
Hi Peter
Thanks.  I had a nasty suspicion that might be the case...:-(  The If was inside a Do.....Loop.  I seem to have solved it by putting an Exit Do on the return, but I had fun trying to get the End If in the right place.  It works now though, so thanks.
Sarah
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

830 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