Control when a form is opened

  • Thread starter Thread starter paxdak
  • Start date Start date
P

paxdak

I have a form that I want to restrict access to.
I only want it to be open from another form and NOT from the DB window.
The other forms change the recordset to a specific record.
From the database window the form opens with entire record set. I don't
want to allow
wholesale changes on all records from this form.

I thought that I could check the RecordCount of the form, and close the
form
if the recordset did not equal 1. I tried the below code. I also tried
the code in the
Form_Load event, but it didn;t work consistently there either. The form
still opens up
from the DB window. If I change to design mode, then view mode, the
routine is run.
What event do I need to put the code into?

or is there a better way to do this?

Private Sub Form_Open(Cancel As Integer)
'Only open if one record is selected
If Me.Form.RecordsetClone.RecordCount <> 1 Then
DoCmd.Close acForm, Me.Name, acSaveNo
Else
'Do some other things
End If
End Sub
 
The best thing to do is to hide the database window and provide a
"switchboard" or similar form that gives users access only to the forms
and other objects that you want them to see.
 
The best thing to do is to hide the database window and provide a
"switchboard" or similar form that gives users access only to the forms
and other objects that you want them to see.

I found the following code to hide/show Databse window:
'To Hide the database window, run
DoCmd.SelectObject acTable, , True
DoCmd.RunCommand acCmdWindowHide

' To show the database window, run
DoCmd.SelectObject acTable, , True

How do you programmatically disable the DATABASE WINDOW in the Menu Bar?
DO you have a sample code for hiding the standard toolbar, replacing with
custom toolbar? And do you have to save the toolbar so that you can load
it
on database exit?
 
All of those options are in

Tools->Startup...

No need for code. In there also is the ability to turn off "Special
Keys" one of which is F11 which is the one that brings up the Database
Window.

These settings can be bypassed by holding down the Shift Key when you
open the database

Brett

I found the following code to hide/show Databse window:
'To Hide the database window, run
DoCmd.SelectObject acTable, , True
DoCmd.RunCommand acCmdWindowHide

' To show the database window, run
DoCmd.SelectObject acTable, , True

How do you programmatically disable the DATABASE WINDOW in the Menu Bar?
DO you have a sample code for hiding the standard toolbar, replacing with
custom toolbar? And do you have to save the toolbar so that you can load
it
on database exit?

Cheers,
Brett
 
Back
Top