Solved

Hidden property for forms through VB??

Posted on 2000-05-15
12
742 Views
Last Modified: 2008-02-01
I'm desperate here :(
I'm creating forms during runtime.
I want to make them hidden.

I tried using the following code for this (Run from a form called test1):

DoCmd.SelectObject acForm, "test2", False
DoCmd.RunCommand acCmdProperties
SendKeys "{TAB} {TAB}{ENTER}", False

This didn't work because the SendKeys won't execute until the properties-window is closed.
Therefore I used another form and a boolean to achieve my goal.
the extra form is called test3

code form_test:

Private Sub Form_Open(Cancel As Integer)
HelpBool = False
End Sub

Private Sub Form_Timer()
DoCmd.SelectObject acForm, "test2", True
If HelpBool = False Then
    HelpBool = True
End If
DoCmd.RunCommand acCmdProperties
End Sub


code form_test3:

Private Sub Form_Timer()
If HelpBool Then
   SendKeys "{TAB}={TAB}{ENTER}"
   HelpBool = False
End If
End Sub


THE QUESTION:

Does anybody know how this can be done using VBA without using sendkeys?? The name and reference of the property I have to change would be nice :)
Since this would allow me to change the hidden property with one line of code, I think this is much more convenient....

Regards,

           Michiel
0
Comment
Question by:GOLLEM
  • 6
  • 4
  • 2
12 Comments
 
LVL 10

Expert Comment

by:paasky
ID: 2811140
Hello GOLLEM,

Did I understand your mission correctly: You're creating new forms run-time and don't want user to see them during that process?

Why not use Application.Echo ?

' disable screen event showing
Application.Echo (False)

....
'do new form creation and other stuff here
...
'close and save new form

' enable screen events
Application.Echo (True)

Note: you should test that everything works okay before disabling echoing and put Application.Echo (True) in error handling code.

Hope this helps,
Paasky
0
 
LVL 9

Expert Comment

by:BrianWren
ID: 2811511
Creating forms at runtime is an undertaking that is almost never necessary.  Why is it that you want to do this?

Also, I don't see what you are trying to accomplish with your code.

You can use

DoCmd.OpenForm "Test2", acDesign

to open a form for design.  Then yuo can create controls on it etc, with no SendKeys required, and, as paasky has said, setting DoCmd.Echo False will prevent anytihing from happening on the screen.

(You really should put up a "Wait . . ." message though.)

Brian
0
 
LVL 9

Expert Comment

by:BrianWren
ID: 2811530
Also, to create a new form, you can use:

     Dim f as Form

     Set f = CreateForm()


This will create a form in the current DB, and the form will be identical to what would be created if you had clicked the New button in the Forms tab of the DB window.

Brian
0
 

Author Comment

by:GOLLEM
ID: 2811769
Paasky, Brian->

I know how to create forms, but that's not what I'm trying to accomplish....

This is what I am trying to accomplish:

If you select a form in the database window, right-click and select properties, you can change the hidden-property to true or false (checkbox).

I want to do the same trough code, but I'd rather not use SendKeys. Again, I already have a solution, but I guess there must be a way to set the hidden-property directly.

So my question is:

How do I set the hidden-property for forms through code directly or at least without using SendKeys


EXTRA INFO
This is why I'm trying to accomplish this:

Basically I use 4 pop-up forms with a subform on them to display my queries. To do this I have to create  datasheet-subforms.
This is not so special, but I'm adding an extra. While creating the datasheet pop-up I'm also creating the module behind it, including some extra functionality.

This extra functionality allows me to click on a field in my queryform to select a record. The main form then displays this record if a valid relation exists.
I have a function that checks for valid relationships between two forms, where the first form acts as a selection-form and the second is updated through the DoCmd.FindRecord method.

I only need a few lines of code to write the module behind my query datasheet-form, because I can loop through my controls and write an On_Click event when the control has a RecordSource property that is not null.

Hope this is clear enough :)

Regards,

         Michiel
0
 

Author Comment

by:GOLLEM
ID: 2811777
P.S. the Hide statement is NOT the same as the hidden-property (to sum up what I said above)
0
 

Author Comment

by:GOLLEM
ID: 2811869
P.S. the Hide statement is NOT the same as the hidden-property (to sum up what I said above)
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 9

Expert Comment

by:BrianWren
ID: 2812144
In the help file, under "Object Properties, (Applies To includes Form object, Module object and Report object):

  .
  .
  .

You can also specify or determine the Object properties by using Visual Basic.

Note: You can only enter or edit the  Description  and  Attributes  properties.   The other Object properties are set by Access and are read-only.

Apparently this is not something that can be readily done.  Why do you want to do this in code?

Brian
0
 

Author Comment

by:GOLLEM
ID: 2812548
Brian->

The hidden-property should be one of the Attributes properties, which are Read-Only, archive, Hidden and System.  The TableDef-object does have this feature (see the Access helpfile for more info)

However, I have looked at both the Document Object (where you would expect to find this feature) and the Form Object and neither of them support the Attributes feature.
I have also looked through the Hidden members of the libraries in the Object Browser, but no luck....


Somehow MS-Access does support this feature though, since you can change it in the Database window. I would just like to know how I can Set the values through VB without having to resort to the solution I posted along with the original question.



The reason I want to accomplish this is that I want to hide the forms from my users, while giving them limited access to the Database window.

Another reason is that in a listbox I present them with the same list of forms that they can normally see in the database-window. The forms I creat for the queries shouldn't be a part of that.
I know that can also be accomplished by standardising the names for the datasheet forms, but to me that is a sloppy solution.

Regards,

          Michiel
0
 
LVL 9

Accepted Solution

by:
BrianWren earned 25 total points
ID: 2812964
When objects get hidden, it is through an entry in one of the MSys... tables—it isn't a 'normal' property.  That's the reason that you can't find this as a property for a form document, (which is where the property would be; I tried creating and appending a property, "Hidden," but that, too, failed).

It seems that what would be best is to hide all the objects before you let your users get their hands on the db...

There has been an intimation that the system tables can be updated, but the expert who said so also said that he was not telling how.  (Your guess is as good as mine regarding whether he was being honest or not...)

Wouldn't our jobs be easier without users...  (Just a thought...)

Brian
0
 
LVL 10

Expert Comment

by:paasky
ID: 2813120
Did the following function yesterday but was unable to post it here because of *very* bad connection (EE is having serious problems again?):

Public Function SetHiddenProperty(FormName As String)
Dim prop As Property
Dim n As Integer
Dim mydoc As Document
   
    On Error Resume Next
    DoCmd.OpenForm FormName
    Debug.Print "Properties of form " & FormName
    For Each prop In Screen.ActiveForm.Properties
        Debug.Print "    " & prop.Name & " = " & _
           prop.Value
    Next
   
    With CurrentDb
       
        Set mydoc = .Containers("Forms").Documents(FormName)
        Debug.Print "Properties of " & mydoc.Name _
            & " container"

        ' just tried to add Hidden property...
        ' result: property is added but it doesn't give the "real" hidden effect.
        Set prop = mydoc.CreateProperty("Hidden", dbBoolean, False)
        mydoc.Properties.Append prop
       
        For Each prop In mydoc.Properties
            Debug.Print "    " & prop.Name _
                & " = "; prop.Value
        Next

        .Close
    End With
   
End Function

And I second you there's no Hidden property in document or form object. :(
0
 

Author Comment

by:GOLLEM
ID: 2813326
Brian, paasky->

On changing the system tables:

Maybe if you use JET directly instead of through MS-Access you will not be restricted in use of the system tables???

Maybe it's possible to trick the JET DB-Engine into thinking MS-Access is sending instructions to change the system tables. Maybe there are programs that can 'intercept' communication, so you can see how to change the tables yourself?


On the question:

Since there seems to be no simple solution through code, I'll simply use the solution I posted.
Too bad though, I guess Microsoft just couldn't resist restricting it's users some more. *LOL*

I want to give both of you points for your input, so  I'm going to accept Brians last comment as the answer and post a dummy question for Paasky


Regards,

          Michiel

P.S. without users there would be no need for us... Brian, where's your spirit? The challenge is to limit the user, while increasing functionality. In the ideal case the user doesn't even know he's being restricted.
 
0
 

Author Comment

by:GOLLEM
ID: 2813330
Brian->

Sorry, but the excellent grade would be the definite solution :)
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now