Results 1 to 8 of 8
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,097

    Make form opened achidden visible

    Just starting some new code to treat some optional backup procedures. Sub TMSExit gets called when the app's session is ending. The user has an option check in app settings as to whether automatic backups are to be enabled. In some instances, the form "frmBkUps" will determine there's nothing to do so I don't even want the form to appear. In testing, the statement "Me.Visible = True" does not result in the form becoming visible. Is something else needed in the OpenForm statement?

    Code:
    
    Public Sub TMSExit()
    If DLookup("BkUpEnabled", "InstProperties") = True Then _
        DoCmd.OpenForm "frmBkUps", , , , , acHidden
    
    
    DoCmd.Quit
    End Sub
    "frmBkUps" Open Event:
    Code:
    Private Sub Form_Open(Cancel As Integer)
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    '  User has automatic backups enabled.  Lets see what needs to be done if
    '  anything.
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    Me.Visible = True
    
    
    End Sub



    I JUST SAW A SCREEN FLASH! I was expecting the form to hold control like acDialog, but it doesn't with acHidden. I think I need to go to bed :-(

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Why would you open a form hidden, and then immediately want it visible in form open?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,879
    Wouldn't DoCmd.Quit close the program? No End IF ?
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  4. #4
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Office 365
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    No End If required as the If statement is all on a single line broken by an underscore.

    FWIW, that sequence of code does make the 2nd form visible for me when it loads.
    Perhaps its a timing issue for you. Try moving the code from Form_Load to Form_Current or even Form_Timer with a timer interval of (say) 1000 to cause a slight delay.
    Last edited by isladogs; 01-30-2025 at 11:57 AM.
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  5. #5
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2021
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,740
    Is there a way for code in TMSExit to determine if frmBKUps need be opened at all, instead of frmBkUps doing so for itself?

  6. #6
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,097
    Sorry for all the confusion. There's no visible property in the form's property sheet in design mode, at least not in A2013. So, I'd been fumbling around trying to learn how to toggle the visibility of a form from VBA. It just didn't occur to me to try "Me.visible =".

  7. #7
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,879
    No End If required as the If statement is all on a single line broken by an underscore.
    Didn't notice the underscore.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  8. #8
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,097
    Maybe the implemented code helps? (The form opens acDialog)
    Code:
    Option Compare Database
    Option Explicit
    Dim strImLib As String
    
    
    Private Sub Form_Open(Cancel As Integer)
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    '  User has automatic backups enabled.  Lets see what needs to be done if
    '  anything.  We'll "Quit" silently if there's nothing to do.  (TMS "Front Gate"
    '  sets TMSDBDLM and TMSImDLM when TMS client session opens.)
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    Me.Visible = False       'Assume for the moment there's nothing to do
        
    If TMSDBDLM <> FileDateTime(TMSClientDB) Then              'Any tables updated?
        Me.tbMsgBoard = "TMS database being backed up now"
        Me.Visible = True
        Me.tbMsgBoard = BkUpDB(TMSClientDB)                    'Post the completion status
    End If
    
    
    strImLib = TMSClientPath & Replace(TMSClientImages, "\", "")        'Leave off the trailing slash
    If TMSImDLM <> FileDateTime(strImLib) Then                 'Any Image library activity?
        Me.tbMsgBoard = "TMS Image Library being backed up now"
        Me.Visible = True
        Me.tbMsgBoard = BkUpIm(strImLib)                       'Post the completion status
    End If
    
    
    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. opened database is not visible
    By felix in forum Access
    Replies: 2
    Last Post: 10-23-2022, 12:10 AM
  2. Replies: 2
    Last Post: 03-09-2021, 05:52 PM
  3. Replies: 17
    Last Post: 08-03-2017, 06:08 PM
  4. Replies: 5
    Last Post: 03-27-2017, 07:48 PM
  5. Replies: 2
    Last Post: 01-06-2011, 04:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums