Runtime Error 6054 referencing all docmd.browseto Navigation subform pathways all of a sudden - ms-access

HELP Please...
All of sudden all of the VBA docmd.browseto code within the entire navigation form has been producing a runtime error 6054 referencing issues with the pathway. These lines of code have worked for months and then all of a sudden stopped working. They work in a backup version from a few days ago when I open it now. I cant figure it out. As far as I can tell the pathways are accurate. I havent changed them, nor have I renamed the main navigation form.
navigation form = frmNavigation example of navigationsubform = frmNewServiceSession
‘DoCmd.BrowseTo acBrowseToForm, "frmnewclientsinfo", "frmNavigation.navigationsubform", , , acFormEdit’
.... regardless of what navigation subform I reference I get the same error code. Again, this worked fine earlier.
Edit*** To test things a bit I had imported frmNavigation and frmNewServiceSession into my most recent backup and they communicate just fine using the exact vba as above.... Something strange is going on

I figured out what was happening although I dont exactly know why. Open to insight, but resolved the immediate issue.
Resolution:
I use to have a Timer form open hidden on autoexec but moved it an action within the Login form on OK button click. For some reason that difference messed with all of the BrowseTo functions.
Thanks

Related

MS Access: query criteria in subform of a navigation form

I have set of cascading combo boxes that query a table and uses criteria this will function without an issue when it's not in a navigation subform. So I have tried to update the query to go through the navigation form and it is not working.
IntelliSense works up to
[Forms]![frmNavigation]![btnNavigationButton]
Then when trying to select FORM it does not come up so I manually enter the reset.
.[FORM]![cboValue]
I have also attempted other syntaxes like the ones mentioned in this link:https://bytes.com/topic/access/insights/599404-referring-items-sub-form
Also, have rebuilt the navigation form from scratch and have run a compact & repair.
I have spent hours searching and trying the different solutions on here and google and the standard ones I have been coming up.
for some reason, the [btnNavigationButton] does not have .Form property is am not sure if there some property that needs to be manually set to get this to work
Thank you for your time.
The user that left a comment answered the question for me. I was setting it to the wrong controller i was selecting the button controller and needed to select NavigationSubform controller appreciate the everyone feedback.

Unable to replicate Refresh All quick access toolbar button in form

I have a form with several subforms whose content is edited in separate forms, opened by command buttons.
When the data in those forms is updated, and the extra forms closed, naturally the main form needs to be refreshed before those changes can be seen. Clicking the Refresh All quick access toolbar button achieves this perfectly.
So I made a macro for the "got focus" event on the main form to refresh it, but it does nothing. I tried repaint and requery as well, applying the latter specifically to the subforms in question, and ran them out of vba instead of an access interface built macro too, none of these seem to solve the problem.
vba coding:
Private Sub Form_GotFocus()
Screen.ActiveForm.Requery
Screen.ActiveForm.Repaint
Screen.ActiveForm.Refresh
Me.sfmContact.Requery
Me.frmCustCert.Requery
Me.frmCustReq.Requery
End Sub
Annoying thing is that if I put this (or even just the macro or Screen.ActiveForm.Refresh) in the on click event of one of the controls it works fine. Just can't seem to make it work in any automatic events that don't require thought or clicks from the end user.
This question is sort of a dupe of Refresh button on an Access form but that question is over a year old, and has no accepted answer. So I've expanded on it.
What you mentioned in your comment there is correct:
My guess is that it's not running it, but I don't know why. I got mixed up between OnActivate and OnLoad, which is why I didn't try that option. That works and solves the problem, but why wouldn't GotFocus fire? Surely the main form lost focus when another form got it for updating, and then it got it back again when the other form closed/anything in the main form was selected...
To avoid this type of error in the future, it may be prudent to specifically name the form in your code instead of using the "Me." command, as that only works for current focus. For instance:
Me.sfmContact.Requery > Forms![FormName].sfmContact.Requery
Alternatively, you could just set the focus to the form in question before that sort of coding.
Forms![FormName].SetFocus

Error upon opening form

I am going crazy with the easiest piece of code that just won't work. I can't fugure out why. I have a button on a form that opens another form but when i click it I get the following error and don't really know what to change:
my code click code is:
Private Sub HSbrowse_Click()
DoCmd.OpenForm "frmSearchPCR"
End Sub
Any Ideas?
I've had this issue several times. I believe that it is caused by the module of your form becoming corrupt. To fix it, set the "Has Module" property of your form to "No" and save and close your form. This will delete the module and any code it contains, so you will need to copy your code first. Open the VBA window to verify that the module was deleted, then reopen your form and set its "Has Module" property back to "Yes" and paste your code back in. This method has solved this problem for me on more than one occasion.
Does the current form has any ActiveX Control in it?
If not then your form may be corrupt,
rebuild your database using e.g. TM-RebuildDatabase
Start by removing individual controls one-at-a-time. When your error goes away you will know the offending control, if that is indeed the problem.
Does the form have underlying data? Did you remove that to see if the problem changes?

Run VBA code whenever a tabbed form is reselected in Access

EDIT: For clarification, I'm talking in the below post about tabbed document browsing, not a Tab Control. However, if you're looking for roughly the same problem but regarding a Tab Control, Gord Thompson's answer is correct. Two answers for the price of one!
I've got an Access 2007 database that uses tabbed documents. I need to run some VBA code every time a user selects the form called "Reports", either via opening it or clicking on its tab if it's already open.
I could achieve much the same thing by closing it each time it's used and running the code on an OnLoad event, but ideally I'd like to keep it open so that users can keep the settings of the various drop down boxes, radio boxes etc that they've already set on "Reports".
I was hoping for an event that could run code on tab reselection, but neither of my guesses (OnCurrent and GotFocus) seem to work (OnCurrent works only when the form is opened, like OnLoad would).
Any ideas greatly appreciated - can't find what I'm looking for on Google, though I suspect that's because I don't know exactly what I'm looking for.
The .Value property of a TabControl returns the index (zero-based) of the current page. So, if I have a TabControl named TabCtl14 that contains two pages, FirstPage and SecondPage, then the code...
Private Sub TabCtl14_Click()
If Me.TabCtl14.Value = 1 Then
MsgBox "SecondPage was clicked."
End If
End Sub
...displays the MsgBox whenever I click the "SecondPage" tab in the TabControl.
Have found the answer I was looking for. It's the OnActivate event.

Problems implementing basic VBA in Access 2007

I'm trying to write some code for my database to enable a dropdown box in a parameter prompt for a query, but it's doing nothing instead of it's intended purpose. This:
Dropdown in Access 2007 parameter query
has been the source of my inspiration. Though I seem to be unable to implement even the most basic VBA code:
Private Sub cmdReset_Click()
Me.cboSelectName = Null
End Sub
(Yes this is not all my code! Just one of the subs)
On the relevant form, I have a button called "cmdReset", which has "[Event Procedure]" for the event "On-Click". I also have a dropdown box called "cboSelectName" on said form. Also I have tried closing the database, and making sure to enable macros when it starts.
So essentially this code should make the value in the dropdown box null when I click the reset button. However it does nothing, it simply deselects the dropdown box. Can anyone help me with this one? I'm keen to start implementing some VBA in my database!
As suggested by Remou, the code wasn't even running. I figured out my problem - I had saved the code in a new module, rather than in the VBA code for my form. Once I shifted the code into the form object, the reset button worked. I've also now got some nifty code working with the actual "generate report" command. VBA really has the power to take your database to a whole new level!