Closing Forms

Gillian

New member
Local time
Today, 03:18
Joined
Mar 12, 2002
Messages
6
I have created various forms and subforms in my database and am using macros to open the new forms. However what i need is for the previous form to automatically close once the new subform has opened.

i tried to use a macro to do this but so far all i have done is confused and frustrated myself as i can not get it work.

I'm currently an A Level student and working against time to produce a database and as i have never used VB or access before, I am struggling quite a lot!

Any help would be very much appreciated!
 
right, you will have obviously created a button to open a form from another. That button should have the on click event proceedure, go into that and copy the information. then go into on close and create an on event proceedure and past the data in, go back to on click and create a macro and set it to close the form. Now when uyou click th button it will close the form and on closing will open the form you have chosen
 
I use this method (and believe me I struggle with Access!) but it works for me.

If you've already used a Macro to open a new form you can simply close the previous form(s) by:

Go into the existing Macro's design view.
Select an Action Type "Close" this is the last action the macro will cerry out.
Select Object Type "Form"
In Object Name select the name of the previous form you want to close.
 
problem with doing a macro to close it on the on close is there is nothing to say open another form.

You need on click close
on close / exit open form required to open

so when you click a button it saying close the form and when closing open the required form.
 
I started access about 12 months ago and didn't even know what VB stood for let alone what it did, thus ran all the commands from macros.
These days my databases dont contain any macros at all.
The way to learn is to let the wizard create an open form or close form button, then study the code behind it.
Basically what you need to do is open the form, set the focus on that form, then close the other form.

The code I have (probably not very tidy or professional) is as follows:
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Service Form"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Maximize
DoCmd.GoToRecord , , acLast
DoCmd.Close acForm, "Switchboard"

As you can see the button on the switchboard form opens the service form,maximizes it, goes to the most recent record then closes the switchboard form.
Good luck, remember write some code, try it, if it doesn't work, smoke won't start coming out of your computer, but will highlight the bit of code that doesn't work or is incorrect. Just keep trying.
HTH
Dave

[This message has been edited by Oldsoftboss (edited 03-16-2002).]
 

Users who are viewing this thread

Back
Top Bottom