Solved

acHidden doesn't fully hide the form

Posted on 2010-11-11
19
1,056 Views
Last Modified: 2012-05-10
Hello Experts,

This is frustrating!

I have a form which opens on startup, and this form opens a form conveniently named "frmHidden" in the background.
frmHidden runs some important "closure" tasks that need to be done when the user closes access.
The database has an extensive menu system that means that they can close the DB when any form is open, which is why I created this "hidden" form.

However. When the form is open, it still appears in the taskbar at the bottom, which I don't want.

If I highlight the form and click Window > Hide it does what I want.

Any suggestions?

Thanks.
0
Comment
Question by:INHOUSERES
  • 8
  • 5
  • 5
  • +1
19 Comments
 
LVL 6

Expert Comment

by:YohanF
ID: 34111718
attach the db... because I use that and works like a magic... so there may be another problem...
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34111753
from Access window
tools > options > View tab

uncheck Windows in taskbar
0
 
LVL 5

Author Comment

by:INHOUSERES
ID: 34111827
Yohan,

I've just discovered that it only does this when the database is first opened.
I have a main menu, and this opens the form hidden but shows at the bottom. If you click a main menu option then go back to the main menu, frmHidden is actually hidden.

capricorn,

This db is used by many people on many machines and I need this to be part of the DB, not access.

Hope this helps.
0
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)

 
LVL 6

Expert Comment

by:YohanF
ID: 34111937
This is what I use "DoCmd.OpenForm "xxxx", , , , , acHidden"

What I do is I open it from the login page and them open up the main menu... give that a try...

although I really dont understand what you mean by shows at the bottom.. ahhahh.. check whether there is another line of code which opens the same thing without acHidden parameter ?

0
 
LVL 5

Author Comment

by:INHOUSERES
ID: 34112048
On the main menu (which is opened as part of the applications "Startup", Not an AutoExec macro) I have the below code which opens the form, but it's not hidden.

if I Open one of the menu's options, it will close the main menu and open another menu with more options.
If this menu is then closed, it then opens the main menu again (which in turn would open the frmHidden again). This time, the form is properly hidden - it doesn't show up in the taskbar or on screen.

and by "taskbar", I mean the windows taskbar.
Private Sub Form_Open(Cancel As Integer)
    DoCmd.OpenForm "frmHidden", , , , , acHidden
End Sub

Open in new window

0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34112102
add codes to check if the form "frmHidden' is already open

Private Sub Form_Open(Cancel As Integer)

if isLoaded("frmHidden")  =true then
    'do nothing
    else

    DoCmd.OpenForm "frmHidden", , , , , acHidden
end if
End Sub


place this codes in a regular module




Function IsLoaded(ByVal strFormName As String) As Boolean
 ' Returns True if the specified form is open in Form view or Datasheet view.
    Dim oAccessObject As AccessObject

    Set oAccessObject = CurrentProject.AllForms(strFormName)
    If oAccessObject.IsLoaded Then
        If oAccessObject.CurrentView <> acCurViewDesign Then
            IsLoaded = True
        End If
    End If
    
End Function

Open in new window

0
 
LVL 5

Author Comment

by:INHOUSERES
ID: 34112473
Let me try explain this with pictures.

I hope they're in the right order.
1 = this is what you see when you open the DB. Notice "frmHidden" in the taskbar.
2 = This is just a random menu which is shown after clicking one of the buttons on the main menu
3 = Click the button in the bottom left of image 2 would take me back a menu, to the main menu again. Notice frmHidden is now gone.

There is no code at all in the other form which references frmHidden.

Hope this explains further.
not-hidden.PNG
random-menu-item.PNG
closing-other-menu-back-to-main-.PNG
0
 
LVL 5

Author Comment

by:INHOUSERES
ID: 34112536
Image one didn't work properly, but frmHidden is there on the taskbar.

I've just created an AutoExec macro which opens both forms. frmHidden is successfully hidden.

Another Bar Stared bug by microsoft?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34112597


call this line in the startup of your application

Application.SetOption "ShowWindowsInTaskBar", 0
0
 
LVL 5

Accepted Solution

by:
INHOUSERES earned 0 total points
ID: 34112709
Capricorn,

I know that would assist this issue, but we do require items to show in the taskbar when they need to be.
I for one am usually cycling between 2 or 3 tables and queries that are open to gather information which I like being in the taskbar.

acHidden should HIDE a form so it's not visible.
If used in a form that is opened from startup, it doesn't work.
Simple as that.

If you want to open 2 forms on startup. One hidden and one not. Use AutoExec.
After that, go to www.microsoft.com and throw up a middle finger.

I hope this helps someone else in future.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34112911
<If you want to open 2 forms on startup. One hidden and one not. Use AutoExec.>

well, that is exactly how this should be done.

this is the way to go when you want to prevent closure of the App when the (X) button in the Access window was clicked
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34112939
here is the link, about this trick
http://www.mvps.org/access/general/gen0005.htm
0
 
LVL 5

Author Comment

by:INHOUSERES
ID: 34113160
Capricorn,

I'm not sure if you've understood the issue at all.
I don't want to prevent my users from closing access when they want.
It would annoy them and I wouldn't be very popular.

This is why I created the hidden form so that It would perform important cleaning duties whatever the user does.
It would always just be there in the background, and when the form's unload event is triggered, badda bing badda boom!
0
 
LVL 6

Expert Comment

by:YohanF
ID: 34113265
Hey

When you open the main menu, do you open it as a Dialog window ???

Just wondering

cheers
Yohan
0
 
LVL 6

Expert Comment

by:YohanF
ID: 34113276
I mean in teh first AutoExec..  And if so make it blank or Normal and try..
0
 
LVL 84
ID: 34116271
Are you sure the comment you've proposed a solution is an actual answer? It seems more like a response to someone else.
0
 
LVL 5

Author Comment

by:INHOUSERES
ID: 34119236
Yohan,

It's not dialog.

LMS.

The first part of the post was a response, but the second part goes onto say that a solution (not necessarily THE solution) was to use an autoexec macro to open both forms, and not to use the initial form to do the work.

The autoexec solves my issue, but doesn't explain why it happens in the first place.
Either way, to my knowledge, running the commands via the macro are no different to actually running it from the form.
I assume the macro just runs it's own little code to open both forms:
docmd.OpenForm "frmMainMenu"
docmd.OpenForm "frmHidden",,,,,achidden

Open in new window


The form triggering the other form was opened on startup, which seems to have caused the issue, because when both forms are open, and frmMainMenu is opened again, the form is officially hidden.

Open to debate I guess! :)
0
 
LVL 6

Expert Comment

by:YohanF
ID: 34119790
Can you put a copy of your database (if you are worried about content/functionality just include only those 2 forms).. Its way easy to debug any errors that way rather than just predicting things...
0
 
LVL 5

Author Closing Comment

by:INHOUSERES
ID: 34143406
solved it myself
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

775 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