Switch from one for to another, and back

garywood84

Registered User.
Local time
Today, 13:10
Joined
Apr 12, 2006
Messages
168
I have a form with a button on it. When the button is clicked, the form it's on closes, and a different one opens up. This second form has a close button, which just closes it down.

I want to modify the close button on this second form so that, when it's clicked, it closes the second form and reopens the first one, displaying the record which was open when the user clicked the button the first time.

Please can someone tell me how to do this? I guess I'll need to store the record displayed on the first form, then code the close button on the second form to open the first form and display that record number? Not sure how to do it though! I've not got very much experience with Access, so please explain in simple terms!

Thanks,

Gary
 
Why not, instead of closing the first form, simply hide it, then from the second form, make it visible again.
 
Also, if you are closing the first form as a means of forcing focus on the second form, you can accomplish by setting the second form's modal property to Yes. The first form can remain open but never can get focus, just like you can't ignore Windows dialog.

(IOW, it may annoy your users slightly) ;)
 
Hiding the first form would work perfectly - I'd just need to requery it after making it visible again, so that it reflects the changes made on the second form.

Please can you tell me how to make it invisible/visible?

Thanks,

Gary
 
Dave,

Thanks for this. Your sample does the kind of thing I want, except that the new record needs to appear on a subform, rather than the main form.

I'm attaching an example database which I've put together, based on what I'm trying to do in my main database. When you open this file, please open the "Centres" form. Click the "Add new contact" button, then enter a new record on the form that is displayed. When you click the Return to Centres button, the Centres form will come back up, but if you pop down the "First name" box on the next black record in the subform, you'll see that the person you entered is not there. If you close the Centres form, then reopen it, the record will be listed.

How can I get the requery to make the list update without the need to close and reopen "Centres"?

Thanks,

Gary
 

Attachments

You were close. You need to save the record in the pop up form and requery the combo box, not the subform.

I added the "Isloaded" function, this checks to make sure the main form is open, and avoids nuisance errors. Also I have taken out the spaces in the sub form name. Spaces become a nightmare when using VBA.

Dave
 

Attachments

Dave,

Many thanks for this. It works exactly as I wanted and I've managed to copy it across into my actual database.

Although it does everything I want, a modification has occurred to me, to improvie it, and I wonder if you'd be able to tell me how to do it. After adding the new Contact and clicking close, the Centres form currently reappears. The user then has to select the person they added in the drop down combo box, to associate them with the centre.

What I'd like to do is have a message box appear when the Centres form reappears, which says something like "Do you want to associate the new link you just added with the current centre?" Yes/No. Clicking yes should automatically set the next form on the subform to the added record. Clicking no should do nothing.

This would just help to ensure that users don't only add the contact to the database and forget to associate them with the centre.

Is it possible?

Thanks,

Gary
 
Try this, you should be able to edit to your requirements...

Dave
 

Attachments

Cheers, Dave. I appreciate your quick response and it looks perfect. I'll have a go at integrating it into my database later and post back to let you know how I get on.

Gary
 

Users who are viewing this thread

Back
Top Bottom