Property 'Sheet' Window - How to close?
Hi,
Access 2003
As far as I can recall, access 2000 and 97 never had the properties sheet re-appearing from design to showing the form. As an upgrade (for some unknown reason) MS have decided to make it appear if you had it open last time (any database) and didn't close it when on a form. :ehh:
By any database I mean, that if you have a fairly secure db and you have the properties sheet closed, then close it - go to a new db open a form, open the properties window, close the form (save if neccessary). Reopen the 'secure' db and when a form opens, so does the properties sheet.
I know you can just close the sheet, but if a user opened the db and got the properties sheet, they may be inclined to uh nose around ... and in doing so accidentally delete something.
Anyone have a link or some code to get to the properties sheet and close it?
:sick:
Re: Property 'Sheet' Window - How to close?
I have seen this issue before too. I guess you just need to make sure that when saving a form's changes from design view, you need
to make sure you close the prop window first.
I suppose you could use the FindWindow, FindWindowEx, and SendMessage APIs to find the window handle of the property window so you
can sendmessage to it telling it to close.
I'll take a look and see if there is a built in method in Access for this though.
Re: Property 'Sheet' Window - How to close?
First try at stopping it.... sort of... Still working on it.
Code:
Dim cbr As CommandBar
Dim cbp As CommandBarPopup
Dim cbc As CommandBarControl
On Error Resume Next
Set cbr = CommandBars("menu bar")
Set cbp = cbr.Controls("&View")
Set cbc = cbp.Controls("&Properties")
cbc.Execute
If Err.Number <> 0 Then
MsgBox "Error : " & Err.Number & vbCrLf & Err.Description, vbOKOnly + vbExclamation, "Error"
End If
Set cbp = Nothing
Set cbc = Nothing
Set cbr = Nothing
Weirdly - if you put a breakpoint in and the execute line it errors (I guess it somehow is confused :confused: and is now looking at the vb editor menu - or just doesn't like you going into debug it when its running.
Still looking for the property of the control to say if it is toggled or not.
Attempt number one :)
:thumb:
Re: Property 'Sheet' Window - How to close?
i tried this in excel, (don't have access)
AppActivate "Properties", True
SendKeys "%{F4}", True
pete
Re: Property 'Sheet' Window - How to close?
West:
But how do you check whether it is open or not?
Wouldn't the send keys close the sheet/db if it was open before all the calls?
Re: Property 'Sheet' Window - How to close?
in excel at least if appactivate finds no window with title "Properties" it generates and error, if you just handle the error to exit sub or skip a line, then it will do nothing
pete
Re: Property 'Sheet' Window - How to close?
There are several toolbar buttons/menu items that are protected from automation. The property button is probably one of them.
Like I posted earlier, the FindWindow & FindWindowEx APIs will do the saerching part for the property window. TheSendMessage API can send
the command to close the property window if FindWindowEx finds it. ;)
Re: Property 'Sheet' Window - How to close?
Just had a quick experiment with FindWindowEx .. looks hmm ok but the properties window doesn't have a title/caption of Properties - can MS make it any harder? :eek:
The title/caption is of whichever control it is in on opening... Or at least was here when I tested it.
Thanks though - I'll think on it some more...
Re: Property 'Sheet' Window - How to close?
Since the prop window has a caption but it all depends on what was selected when the prop window was last closed, you could
just search for the class name only - "OArgDlg"