Close form on button click

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a mainform that opens when db is launched.
I have it set so that it opens to a blank record
with a combo box to find the correct record.
If user sees correct record with information , he clicks a button to open
another form(lets call it Form2) to enter data.
Once Data is entered into Form2, I have a button taking user back to
MainForm, and I want it to once again be blank.
It retains the last person entered into the combo box.
I am thinking that is because the mainform remains open when you go to
Form2, so how can I get the mainform to close when you click the button to go
to Form2.

Thanks!!
 
Add the following line to the code in the Click event procedure of the button
on the first form after the line which opens Form2 (assuming you are not
opening it in dialogue mode)

DoCmd.Close acForm, Me.Name

Your second form would then have to reopen the first form of course, which
is a bit less efficient than leaving it open (and possibly hidden by setting
its Visible property to False) and just moving it to a blank record and at
the same time setting the combo box's value to Null when you open Form2.

Closing the first form also assumes that the second form is not being
restricted to the relevant record(s) by a parameter in its underlying
RecordSource which references the combo box on the first form.

Ken Sheridan
Stafford, England
 
how can I get the mainform to close when you click the button to go
to Form2.

Put a line in the button's click event code:

DoCmd.Close acForm, Me.Name

John W. Vinson [MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top