Operating Views in Final Product Release

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NDayave
    New Member
    • Feb 2007
    • 92

    Operating Views in Final Product Release

    Hi all,

    I was wondering if it is possible to get the database forms to open separate of the main Access window that appears in the background. I've had a poke around the menus and can't find anything.

    I'm sure I've seen Access databases that don't require the main Access window to run, or have I just made a bit of a mistake?

    Thanks in advance,

    NDayave
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32668

    #2
    Sure NDayave, just check out Tools \ Startup...

    Comment

    • NDayave
      New Member
      • Feb 2007
      • 92

      #3
      Originally posted by NeoPa
      Sure NDayave, just check out Tools \ Startup...
      Yeah, I got to that bit to get rid of the menus etc. but I mean the entire grey background window with File | Edit | View etc on it, so the forms appear as if they are popups, without Access full screen in the background.

      I know it's not really a necessity, it just annoys me that the user cannot use another window in the background to, for example, use as reference for data entry.

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32668

        #4
        Ah, that's a different story.
        Well, technically, as the Access database is open in the Access window, no - it's not possible.
        However, the main Access window doesn't need to be maximised. That would enable the user to have other windows visible and usable on the screen at the same time. I feel there aught to be other options, like a View in Full Screen option that strips toolbars etc, but I couldn't find any reference to it I'm afraid.

        Comment

        • NDayave
          New Member
          • Feb 2007
          • 92

          #5
          Okay then, thanks for taking a look anyways,

          NDayave

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32668

            #6
            No problems.
            Let us know if you come up with anything that takes you any further and good luck :)

            Comment

            • NDayave
              New Member
              • Feb 2007
              • 92

              #7
              How do,

              Old thread I know, but I was looking through and realised I had found a solution to the full screen thing, it doesn't combat ALT+Tab key entries, but then nothing ever seems to. What you end up with is the Access window fullscreen - F11 browser style - with no toolbars or the taskbar:

              Save two Modules:

              Kiosk Mode
              Code:
              Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
              Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
              Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
              Private Const GWL_STYLE = (-16)
              Private Const WS_CAPTION = &HC00000
              Private Const WS_BORDER = &H800000
              Private Const SWP_NOZORDER = &H4
              Private Const SWP_NOMOVE = &H2
              Private Const SWP_NOSIZE = &H1
              Private Const SWP_NOACTIVATE = &H10
              Private Const SWP_FRAMECHANGED = &H20
              Private Const SWP_DRAWFRAME = SWP_FRAMECHANGED
              
              
              Public Sub ToggleKioskModeAlike()
                  Dim NewStyle As Long
              
                  NewStyle = GetWindowLong(Application.hWndAccessApp, GWL_STYLE) Xor (WS_BORDER + WS_CAPTION)
                  SetWindowLong Application.hWndAccessApp, GWL_STYLE, NewStyle
                  SetWindowPos Application.hWndAccessApp, 0&, 0, 0, 0, 0, SWP_NOZORDER Or SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOACTIVATE Or SWP_DRAWFRAME
                  Application.CommandBars("menu bar").Enabled = Not Application.CommandBars("menu bar").Enabled
              End Sub
              Hide Taskbar
              Code:
                    Dim handleW1 As Long
              
                    Private Declare Function FindWindowA Lib "user32" _
                    (ByVal lpClassName As String, _
                    ByVal lpWindowName As String) As Long
              
                    Private Declare Function SetWindowPos Lib "user32" _
                    (ByVal handleW1 As Long, _
                    ByVal handleW1InsertWhere As Long, ByVal w As Long, _
                    ByVal X As Long, ByVal Y As Long, ByVal z As Long, _
                    ByVal wFlags As Long) As Long
              
                    Const TOGGLE_HIDEWINDOW = &H80
                    Const TOGGLE_UNHIDEWINDOW = &H40
              
                    Function HideTaskbar()
                       handleW1 = FindWindowA("Shell_traywnd", "")
                       Call SetWindowPos(handleW1, 0, 0, 0, _
                       0, 0, TOGGLE_HIDEWINDOW)
                    End Function
              
                    Function UnhideTaskbar()
                       Call SetWindowPos(handleW1, 0, 0, 0, _
                       0, 0, TOGGLE_UNHIDEWINDOW)
                    End Function

              To start:
              Code:
              Private Sub StartKiosk_Click()
              Call ToggleKioskModeAlike
              Call HideTaskbar
              DoCmd.ShowToolbar "database", acToolbarNo
              DoCmd.ShowToolbar "Form view", acToolbarNo
              DoCmd.ShowToolbar "menu bar", acToolbarNo
              RunCommand Access.AcCommand.acCmdAppMaximize
              End Sub
              To Revert back:
              Code:
              Private Sub EndKiosk_Click()
              Call UnhideTaskbar
              DoCmd.ShowToolbar "database", acToolbarYes
              DoCmd.ShowToolbar "Form view", acToolbarYes
              DoCmd.ShowToolbar "menu bar", acToolbarYes
              RunCommand Access.AcCommand.acCmdAppRestore
              DoCmd.Restore
              Call ToggleKioskModeAlike
              End Sub
              Hope this helps,

              NDayave

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32668

                #8
                Thanks for posting a solution. That's always welcome :)

                Can you tell me if this solution is likely to leave Access mucked up (without some of its bits) if it were to crash though? Assuming a loss of code context, would it revert automatically to a normal Access window for the next user (database) or might it leave the changes?

                Comment

                • NDayave
                  New Member
                  • Feb 2007
                  • 92

                  #9
                  After having a play, in the case of a crash, it will leave Access without the toolbars and menu bar. If you used the hide taskbar as well, you would also be left without the taskbar.

                  Basically I wouldn't use this unless you know you'll be at the computer when, or shortly after, any crashes that occur, or the user is aware of how to get them back.

                  Obviously to get them back you just need to run the appropriate code again.

                  Is there anyway to run VBA outside of Access? Maybe stored in an external file and run on a crash?

                  Comment

                  • NeoPa
                    Recognized Expert Moderator MVP
                    • Oct 2006
                    • 32668

                    #10
                    With Application Automation you can control Access externally. This is most often found from other Office applications, but can be done completely externally I believe.

                    A small application that autoruns code to revert the settings may be useful. Alternatively, these are probably stored as registry settings so could be saved and re-applied when necessary simply by double-clicking on the saved .REG file (or even a shortcut to it created).

                    Comment

                    • NDayave
                      New Member
                      • Feb 2007
                      • 92

                      #11
                      In looking into transparent forms, I came across a rather simple solution to your "Run in Fullscreen" problem.

                      If you simply want a solid colour to fill the whole screen, make a form with that colour Detail and set:
                      - Scroolbars = Neither
                      - Record Selectors = No
                      - Navigation Buttons = No
                      - Dividing Lines = No
                      - Auto Resize = No
                      - Auto Centre = Yes
                      - Pop up = Yes
                      - Modal = No
                      - Border Style = None

                      In the form's VBA enter
                      Code:
                      Private Sub Form_Resize()
                          Me.Painting = False
                          DoCmd.Maximize
                          Me.Painting = True
                      End Sub
                      On the form that opens with the database, On Load enter:
                      Code:
                          With DoCmd
                              .Echo False
                              .OpenForm <FormName>
                              .Echo True
                          End With
                      and On Close Enter:
                      Code:
                      If (CurrentProject.AllForms(<Form Name>).IsLoaded) Then
                              DoCmd.Close acForm, <Form Name>
                      End If
                      This will fill the entire background of the screen and provided you set your other forms to Pop Up as well it will stay that way.

                      If you want to make it transparent for a dimming effect for errors or logins etc. add a module:
                      Code:
                      Private Declare Function GetWindowLong Lib "User32" Alias "GetWindowLongA" _
                        (ByVal hWnd As Long, _
                         ByVal nIndex As Long) As Long
                      
                      Private Declare Function SetWindowLong Lib "User32" Alias "SetWindowLongA" _
                        (ByVal hWnd As Long, _
                         ByVal nIndex As Long, _
                         ByVal dwNewLong As Long) As Long
                      
                      Private Declare Function SetLayeredWindowAttributes Lib "User32" _
                        (ByVal hWnd As Long, _
                         ByVal crKey As Long, _
                         ByVal bAlpha As Byte, _
                         ByVal dwFlags As Long) As Long
                      
                      Private Const LWA_ALPHA     As Long = &H2
                      Private Const GWL_EXSTYLE   As Long = -20
                      Private Const WS_EX_LAYERED As Long = &H80000
                      
                      Public Sub SetFormOpacity(frm As Form, sngOpacity As Single)
                          Dim lngStyle As Long
                      
                          ' get the current window style, then set transparency
                          lngStyle = GetWindowLong(frm.hWnd, GWL_EXSTYLE)
                          SetWindowLong frm.hWnd, GWL_EXSTYLE, lngStyle Or WS_EX_LAYERED
                          SetLayeredWindowAttributes frm.hWnd, 0, (sngOpacity * 255), LWA_ALPHA
                      End Sub

                      and change the resize sub on the background form to:
                      Code:
                      Private Sub Form_Resize()
                          Me.Painting = False
                          DoCmd.Maximize
                          SetFormOpacity Me, 0.7
                          Me.Painting = True
                      End Sub

                      Comment

                      • hedges98
                        New Member
                        • Oct 2009
                        • 109

                        #12
                        NDayave - I tried to use your code in the last post on my database but I get an error (code 2450) on this code
                        Code:
                          With DoCmd 
                                .Echo False 
                                .OpenForm <FormName> 
                                .Echo True 
                            End With
                        Line 3 comes up highlighted when debugged. Just to make sure I'm not being stupid, the <FormName> refers to the background form, right?

                        Cheers!

                        Comment

                        • NDayave
                          New Member
                          • Feb 2007
                          • 92

                          #13
                          Hi hedges,

                          It looks like you haven't referenced your form correctly.

                          If it is called frmBackground, then the line would be:
                          Code:
                          With DoCmd 
                                  .Echo False 
                                  .OpenForm "frmBackground"
                                  .Echo True 
                              End With
                          Hope that helps,

                          NDayave

                          Comment

                          • hedges98
                            New Member
                            • Oct 2009
                            • 109

                            #14
                            Yep, I was missing the quotation marks. Will give it a bash now, thanks for the prompt reply!

                            Comment

                            • NDayave
                              New Member
                              • Feb 2007
                              • 92

                              #15
                              No problem, post back if that's got everything sorted.

                              Point to note: Access can't (to my knowledge) intercept the ALT-TAB shortcut so although your app will be completely full screen, it can still be navigated away from. If you do know how to stop those kind of Windows shortcuts, I'd be very grateful to hear about it.

                              Comment

                              Working...