Quit & Open

  • Thread starter Javier G via AccessMonster.com
  • Start date
J

Javier G via AccessMonster.com

Is is posible to Quit from Access and return to the same form ??
of course I tried with the following code but is Not working

Private Sub Command4_Click()
DoCmd.Quit
DoCmd.OpenForm ("MyForm")
End Sub

Any sugestion ??

Regards
 
D

Dirk Goldgar

Javier G via AccessMonster.com said:
Is is posible to Quit from Access and return to the same form ??
of course I tried with the following code but is Not working

Private Sub Command4_Click()
DoCmd.Quit
DoCmd.OpenForm ("MyForm")
End Sub

Any sugestion ??

Regards

Not in any simple, easy way. Why would you want to do this?
 
J

Javier G via AccessMonster.com

Thank Dirk you for answering !

The main reason is to refresh the new active MDW file linked to the DB.

Regards
 
D

Dirk Goldgar

Javier G via AccessMonster.com said:
Thank Dirk you for answering !

The main reason is to refresh the new active MDW file linked to the
DB.

Could you explain a bit more? If this is in fact necessary, you might
need to write an external script --e.g., a .vbs file -- and shell to it.
The script file could get a reference to the current Access application,
close it, then open Access again and (by automation) get it to open the
desired form.

Another alternative would be to set the desired form, at least
temporarily, as the database's startup form. Then all you'd need to do
is close the database and open it again, or compact it. You can do
*that* from within the running application, so long as you're running
Access 2000 or later. However, I'm not sure whether that is going to
give you the MDW refresh you're talking about. If you need to exit the
Access session completely, that won't do it.
 
R

Rick Brandt

Javier said:
Thank Dirk you for answering !

The main reason is to refresh the new active MDW file linked to the
DB.

Regards

Launch a new instance of your app and then close the old one (in that
order).
 
J

Javier G via AccessMonster.com

Thank you a lot Rick & Dirk !!

Now I can start working,......... ;-))))
regards
 
D

David Mueller

Can someone give me some syntax suggestions to make this happen?

1. My front end works with many back ends.
2. Users can "point" the front end to any back end.
3. After users point to a new back end, I need to close and reopen.
 
R

Roger Carlson

I'm not sure why you need to close and open again, but Dirk was referring to
a manual close and reopen or compaction. That you can do from within a
running application. In order to programmatically close and reopen (or
compact) a database, I usually 1) programmatically create a new database, 2)
export a module and a macro to the new database, 3) launch the new
database, executing the macro with the x/ switch, 4) close existing
database. The macro I export only has one action and that runs the function
in the module. The module has code to either opens the previous database or
compact the previous database.

On my website (www.rogersaccesslibrary.com), is a small Access database
sample: "CompactDatabase.mdb" which illustrates how to do this.

--
--Roger Carlson
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
D

Dirk Goldgar

David Mueller said:
Can someone give me some syntax suggestions to make this happen?

1. My front end works with many back ends.
2. Users can "point" the front end to any back end.
3. After users point to a new back end, I need to close and reopen.

Like Roger Carlson, I'm not sure why you need to close and reopen. If
it's just a matter of relinking the tables or refreshing the links, you
can do that without closing the database.

That said, in Access 2000 or later you can compact the database -- which
would automatically involve closing and reopening it -- with code like
this:

Public Sub CompactDB()

CommandBars("Menu Bar"). _
Controls("Tools"). _
Controls("Database utilities"). _
Controls("Compact and repair database..."). _
accDoDefaultAction

End Sub
 
D

David C. Holley

Those here that have been around know the question I'm about to ask...

*WHY* does the database need to be closed? Do you have global variables
that need to be cleared? As long as the schema for the back end DB's are
the same, I personally can't see any *specific* reason why you would
have to.
 
D

David C. Holley

P.S. Pulling the plug of your PC or laptop out of the electrical outlet
isn't the only way to turn off the computer. You can flip the circuit
breaker off. (ROTFLMOAO)
 

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

Top