Solved

Hidden property for forms through VB??

Posted on 2000-05-15
12
738 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
P.S. the Hide statement is NOT the same as the hidden-property (to sum up what I said above)
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 9

Expert Comment

by:BrianWren
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Brian->

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

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

771 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

11 Experts available now in Live!

Get 1:1 Help Now