Hiding Object Browser and running into a weird issue (1 Viewer)

BeardedSith

Member
Local time
Today, 13:15
Joined
Feb 5, 2020
Messages
71
I have a procedure I created (let's be real, it's stupid simple...) and call each time a form is loaded. But I'm having an issue with one specific form and getting it to work correctly.

Here's the procedure:
Code:
Public Function FormStartUp()
 DoCmd.SelectObject acTable, , True
 DoCmd.RunCommand (acCmdWindowHide)
End Function
I just "Call FormStartUp()" with each On Load Event in the database. It works great for every form except one.
The form in question in my "main" data entry form. There are others, but most everything in the database revolves around this one form.

Here's the On Load:

Code:
Private Sub Form_Load()

On Error GoTo Form_Load_Err
'Call FormStartUp
FilterList
Call IssueRewards

Dim CusID, rst As Recordset

CusID = Nz(Me.OpenArgs, 0)
If CusID > 0 Then
    Set rst = Me.RecordsetClone
    rst.FindFirst "ID = " & CusID
    If Not rst.NoMatch Then
        Me.Bookmark = rst.Bookmark
    End If
    rst.Close
Else
    DoCmd.GoToRecord acDataForm, Me.Name, acNewRec
End If

Form_Load_Exit:
    Exit Sub
Form_Load_Err:
    MsgBox Error$
    Resume Form_Load_Exit
End Sub
So I've moved "Call FormStartUp" around within the procedure, but each time I get a different issue popping up. If I leave it where it is (albeit uncommented), I get an error that states "The command or actions 'GoToRecord' isn't available now". When the form opens, the object browser is still showing or reappears. If I move the line lower, past the OpenArgs block, I don't get the error, but it also makes the Object Browser reappear. When it's commented out (like it is in the snippet above), nothing happens and the object browser reappears when you open the form. This procedure works for every other form in the database, but for some reason not this one. It appears as though the OpenArgs block might be interfering with the procedure, but I have no clue how or why.

Ideas? I tried leaving it out and just using it on my other forms, but when the database opens this form, no matter what, it shows the object browser.
 

isladogs

CID
Local time
Today, 18:15
Joined
Jan 14, 2017
Messages
13,602
is that your startup form when the app is loaded?
Try adding the line DoEvents after the Formstartup line to give time for that procedure to complete before the next line of code is run.

If that still fails you could run the code from an autoexec macro instead.
In fact unless you are later displaying the navigation pane for some reason, there should be no need to keep hiding it.
Just hide the nav pane at the start and leave it hidden

BTW the brackets in the DoCmd line are superfluous as is the use of Call. Neither do any harm but nor are they needed.
 

BeardedSith

Member
Local time
Today, 13:15
Joined
Feb 5, 2020
Messages
71
is that your startup form when the app is loaded?
Try adding the line DoEvents after the Formstartup line to give time for that procedure to complete before the next line of code is run.

If that still fails you could run the code from an autoexec macro instead.
In fact unless you are later displaying the navigation pane for some reason, there should be no need to keep hiding it.
Just hide the nav pane at the start and leave it hidden

BTW the brackets in the DoCmd line are superfluous as is the use of Call. Neither do any harm but nor are they needed.
This is NOT my startup form. That form seems to be working just fine. The navigation pane isn't needed for the end-user, so no, I don't really have to keep calling the code over and over again. But right now, no matter if the code is there or not, the nav pane shows up when I open this form. Even with the call for the procedure being commented out. So, you're right, I don't need the code running on any forms other than my start-up form, but for some reason it keeps showing back up on this one, specific form.

EDIT: I guess I didn't test this out enough, but the nav pane shows up on ALL forms (there's only two other forms the user generally accesses) outside of the start-up form. Essentially, the only form it hides itself on is the start-up form. But it's using similar "calls".

Here's that form's Load:
Code:
Private Sub Form_Load()
    Dim rst As DAO.Recordset
    Set rst = CurrentDb.OpenRecordset("SELECT " _
        & "First(Nz([tblOptions]![LastReport],DateSerial(Year(Now()),1,1))) AS Daily," _
        & "IIf(Nz([tblOptions]![LastReport],DateSerial(Year(Now()),1,1))<>FormatDateTime(Now(),2),1,0) AS PublishReport," _
        & "CDate(First(Nz([tblOptions]![LastBackup],'Never'))) AS BackUp " _
        & "FROM tblOptions GROUP BY IIf(Nz([tblOptions]![LastReport],DateSerial(Year(Now()),1,1))<>FormatDateTime(Now(),2),1,0)")
    Dim BackupDate As String
    DoCmd.MoveSize , , 6 * 1440, 3.25 * 1440

   
    If rst!PublishReport = 1 Then
        Me.lblDaily.ForeColor = 255
        Me.lblDaily.Caption = rst!Daily
        Me.lblDaily.FontBold = True
    Else
        Me.lblDaily.Caption = rst!Daily
    End If
   
    BackupDate = DateSerial(Year(Now()), Month(Now()), Day(Now() - 7))
   
    If CDate(BackupDate) > CDate(rst!Backup) Or rst!Backup = "Never" Then
        Me.cmdBackUpNow.Visible = True
        Me.lblBackup.ForeColor = 255
        Me.lblBackup.Caption = rst!Backup
        Me.lblBackup.FontBold = True
    Else
        Me.lblBackup.Caption = rst!Backup
    End If
   
    Me.txtDaily.Caption = DateSerial(Year(Now()), Month(Now()), Day(Now()))
    Me.txtLastDaily.Caption = CDate(rst!Daily)
   
    Call FormStartUp
    Call IssueRewards
   
End Sub
 
Last edited:

isladogs

CID
Local time
Today, 18:15
Joined
Jan 14, 2017
Messages
13,602
OK so first try adding DoEvents as previously suggested.

But I would recommend you hide the nav pane from standard users in Access options and apply other security measures to prevent them reversing that. Then add code to show the nav pane but which only runs when a program admin /developer is using the app
 

BeardedSith

Member
Local time
Today, 13:15
Joined
Feb 5, 2020
Messages
71
OK so first try adding DoEvents as previously suggested.

But I would recommend you hide the nav pane from standard users in Access options and apply other security measures to prevent them reversing that. Then add code to show the nav pane but which only runs when a program admin /developer is using the app
Adding "DoEvents()" after Call FormStartUp gives me a compile error: Expected: =

Never used DoEvents(), googled it, and still not entirely sure what it does outside of "pausing" the processes for Windows to "catch up", so-to-speak.

I would LOVE a better method to hiding the navigation pane that what I'm using. I got this method out of an example I downloaded on StackExchange several years ago. I wish I knew where I got it and who wrote it up, but it wasn't me. Either way, it's still really simple method, but if it's not the best method, I would love to have some ideas where to go for improving this functionality (hiding the db window from "common folk" lol)
 

isladogs

CID
Local time
Today, 18:15
Joined
Jan 14, 2017
Messages
13,602
Apologies, I thought I had replied to this on Friday.

DoEvents is not a function. Remove the (). As already stated, it allows Access time to complete one task before the next is started.

You are using the standard method of hiding the navigation pane. However it is certainly possible to tidy up the code, especially if you are using it repeatedly. You could look at my example app which does that and more besides Control the application interface.

Hope that helps
 

BeardedSith

Member
Local time
Today, 13:15
Joined
Feb 5, 2020
Messages
71
I'll take a quick look at your example and try to model mine on yours. I tried putting DoEvents in, and I got the same error stating GoToRecord isn't available right now.
 

BeardedSith

Member
Local time
Today, 13:15
Joined
Feb 5, 2020
Messages
71
Holy crap, @isladogs - You're where I got the original idea for this entire process lol. /wave

EDIT: Typo
 
Last edited:

BeardedSith

Member
Local time
Today, 13:15
Joined
Feb 5, 2020
Messages
71
Tinkering around with your modNavPaneTaskbar, I'm having the exact same problem on my forms. One will hide the nav pane, then the next form displays it.

I just exchanged my function with your HideNavigationPane() function, and put HideNavigationPane in where I had FormStartup().
 

isladogs

CID
Local time
Today, 18:15
Joined
Jan 14, 2017
Messages
13,602
Ha! The wheel goes full circle!

Certain actions will always trigger the nav pane to reappear automatically. For example importing/linking a new table using code.
I don't have a complete list of such actions but where an action does cause it to reappear, all you can do his hide it again immediately.
As this causes some screen flicker, its best to switch off screen updating first...but do remember to switch it on again!
 

BeardedSith

Member
Local time
Today, 13:15
Joined
Feb 5, 2020
Messages
71
If I wanted to put my/your function somewhere else, perhaps on On_Open or On_Current? I don't want to call the procedure too often, because I'm sure it'll cause several other problems. Is there a better method to accomplish the hiding of the "bit's n' piece's" of Access so the user is presented solely with the forms they need to work with.

One thing to note, the people who use this database are very bad at technology. It's kind of humorous, but not when I'm trying to put something together for them to use lol. I'm working on trying to incorporate your modDatabaseWindow module, but hiding the entire Access screen might cause some emotional trauma from the users...lol Either way, it might be the only way to hide the "dangerous bits" of Access from those who don't know what they're clicking on....lol
 

isladogs

CID
Local time
Today, 18:15
Joined
Jan 14, 2017
Messages
13,602
I have occasionally used Form_Open but from experience, Form_Load is better.
I definitely wouldn't use Form_Current as that can be triggered repeatedly and would lead to distracting screen flicker.

As my end users never see the ribbon or nav pane and as I use overlapping windows display rather than tabbed documents, hiding the application interface is a natural progression. FWIW, I also use automatic form resizing.
In almost 20 years, I've never had any negative feedback from clients about any of the above.
Of course, your experience may be different. 😀
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom