Microsoft Access calculated control breaks in Navigation Form - ms-access

I have a form in Microsoft Access 2013 that uses the following formula in a calculated text box to summarize outcomes:
=DCount("[Log]![Outcome]","[Log]","[Log]![Outcome] ='Good' AND [Log]![User]= [Forms]![User Summary]![UserName]")
In effect, the formula looks in the "Log" Table and gives me the total count where the "Outcome" is "Good" for the User that matches the current user selected in the "User Summary" form.
The formula works great when I access the "User Summary" form directly. However, if I embed the "User Summary" form into a navigation form, the formula returns an error. The error stops and normal behavior resumes if I open the original "User Summary" form in the background.
Any ideas how to make this work in a Navigation form without having to open the User Summary form in the background? I eventually will be handing the interface to multiple people, and I don't want them to have to open various forms in the background just to get the navigation to work.

Try this:
=DCount("[Log]![Outcome]","[Log]","[Log]![Outcome] ='Good' AND [Log]![User]='" & Me.MySubformName!UserName & "'")
A bit simplified:
=DCount("Outcome","Log","Outcome='Good' AND User='" & Me.MySubformName!UserName & "'")
Where MySubformName is not the name of the form but the name of the control in the main form that contains the subform.
Depending on where your control is you may need to do something like Forms.MyMainForm.MySubForm!UserName. Basically when your form is embedded in another form you have to call it by starting from the main form and work downwards.

The inbuilt Navigation form uses a subform to display your forms.
Unfortunately they also unload the form from the subform container when it isn't selected, so that form isn't actually present in the background. Whilst this is a clever technique to improve perceived performance, it isn't without it's issues if you don't know it's doing it.
This is why most developers make their own Navigation forms.

Related

Forms sometimes open as tabbed documents and sometimes not

I am working in Access 365 and am struggling with forms that sometimes launch as pop-ups and sometimes launch as tabbed documents.
My database Options-->Datasheet-->Document Window Options are set to Tabbed Documents and checked for Display Document Tabs.
My form Properties are set to Popup = No and Modal = No.
I'm going around in circles trying to figure out a pattern as to why sometimes the same form will open as a tab but other times open as a pop-up.
Here is one example: I have a navigation form that shows a list of customers, and double-clicking on the customer name fires off a simple macro that does the following:
DoCmd.OpenForm "frmCustomerInfo", _
WhereCondition:="[ID] = " & Me.[ID], _
DataMode:=acFormEdit, _
WindowMode:=acDialog
However, when I launch the CustomerInfo form from the navigation form, it is opening as a pop-up.
Can anyone help provide some insight? Is there another setting that I'm missing?
Thanks in advance.

Generating reports through a form and the navigation pane

Right now I have a report that is generated by clicking a button on a form. The criteria for the report is what the user selects in a combo box. That works fine, but when I click on the report in the navigation pane, it tells me to enter "Forms!Adjudication!Combo21" because that is the criteria it uses on the form. I was wondering if I can change that to say something like "Enter release event" that will show up when I click on the report in the navigation pane, but also leave the option to generate the report through the form?
well since your query is looking for that combo field, when the form is closed, it wont find it. however, the query is already prompting you to enter a value, so you can just enter a value in that box and it will work fine. no need to over do this. if you are looking to change the label to "Enter Release event", then consider changing the combo box's name on the form Adjudication to something that will make sense to the user, like instead of "Combo21", change it to "ReleaseEvent". That way the prompt should return "Forms!Adjudication!ReleaseEvent".
sure you can do more here to, but like i said, probably not necessary to over complicate this.

Microsoft Access 2013 Button Issue

I have kind of a two part issue (they may be related, I'm not sure). I've never worked with Microsoft Access 2013 before (or any Access version really), and using a "for dummies" type book I'm trying to build a front end interface to link to a SQL database. To do this I'm using the navigation form, regular forms, and then the tables themselves in subforms within that. The forms that hold the subforms are also where I'm placing my buttons. My intentions with these buttons are to use them to filter the table to specific records. I have one doing that successfully (via the main navigation form) but then I have the problem of all the other buttons not working at all, or calling the same text box that that one calls.
This is the code to the working button:
I added the stop Macros actions in an effort to keep the same box from popping up when I pressed another button that houses the macro with a show all records action. Because of issues I also added a stop macro action before the show all records actions on this button (I would do a picture but I'm only allowed two links per the site rules).
This one I found when I added the stop action to the macro before the show all action it stopped the box from popping up, but it also doesn't work to show me all the records. Without the stop action, it acts exactly like the Search Mill ID Button.
The second part of my issues is that my third button currently does show me all records despite it being me trying to use it as a search feature to have a box pop up and the user enter in all or part of a company name to filter the records.
That code looks like this:
I am pretty sure there are a few things wrong with the code on this button in general, but have been having trouble finding any resources of people who are having the same problems as me (or perhaps the issue is so basic most users just automatically know what to do). I've been relying on youtube videos and an access for dummies book to try to build this stuff, but realize that I'm a little beyond my skills; however, I still have to get it done for my job so I'm persevering through.
I appreciate any tips/suggestions to help!
One approach would be to set the OnClick event of your button to use VBA code (Event Procedure), and get the Mill_Id from an Input Box. Macros are much more limiting than VBA and you cannot reasonably use error handling. You can then set the RecordSource property of the form when the button is clicked. The buttons OnClick event would be something like this:
Private Sub Command0_Click()
s = InputBox("What is the Mill ID?", "Mill ID", "")
Me.RecordSource = "SELECT * FROM MyTableWithMillData WHERE Mill_ID = '" & s & "'"
End Sub
Or if the button is on a parent form, and you're trying to change the subform, use this:
Private Sub Command0_Click()
s = InputBox("What is the Mill ID?", "Mill ID", "")
Me!subformcontrolname.Form.RecordSource = "SELECT * FROM MyTableWithMillData WHERE Mill_ID = '" & s & "'"
End Sub

form submitting with onLoad input values instead of user inputted values when automated with VBA

Main Issue: When I submit a form using vba, the form's inputs' values change unexpectedly. I'm looking to see if there's an issue I don't know of with document.forms().submit in vba that might be related?
Code first, explanation follows:
htmlwindow.Document.getElementById("ReportNum_DropDownList").selectedIndex = 15
htmlwindow.Document.getElementById("ToMMYY_TextBox").Value = QtrMo & "/" & QtrYr
htmlwindow.Document.getElementById("FromMMYY_TextBox").Value = QtrMo_min2 & "/" & QtrYr
htmlwindow.Document.getElementById("ReportCols_DropDownList").selectedIndex = 2
htmlwindow.Document.getElementById("__EVENTTARGET").Value = "Display"
htmlwindow.Document.forms("Form1").submit
Using vba in excel I open IE, navigate to a login page and login, then arrive at "Reports" page which has "Form1", which has several elements.
When the Reports page loads, all of Form1's inputs have pre-loaded values from the last time I used the website. For instance input "FromMMYY_TextBox" is a text box that already reads "08/15" when the Reports page loads. I have several lines of code that update the inputs, including "FromMMYY_TextBox". Then I submit the form, and when it submits, it ignores the new values in the inputs and uses the pre-loaded values that populated the inputs upon originally loading the page. So if I made "FromMMYY_TextBox".Value = "09/15", it submits as "08/15" for some reason.
There is no "on_submit" in the element. I also tried to clear history/cookies/form submissions/passwords/etc from IE and do this, but when the Reports page loads, the inputs are still pre-populated. When I use ".click" on Form1's submit button, I have a more "intense" problem so that's ruled out as an option I think.
Is there anything strange about document.forms().submit that might cause this? Or should I try to see if I'm tripping some kind of validation code? I'm lost on what could cause this.
Edit: When I use ".click" on the Form's submit button, the form submits with the correct input values, but it will not display in the browser like it should. Instead it attempts to download the table as an excel file, which I do not want.
Edit2: I turned off auto-complete in IE and it did not help.

Access 2010 - What Control Name do I use to Requery this Subform?

I am now learning MS Access and I have run into a problem. I have found similar questions but after trying them I still can't figure this out.
I have added a button on a form that updates a table behind a subform and I now need that subform to display the new data. Can anyone tell me what to use as the Control Name or if I'm even on the right track to get what I want?
My main form is "EnterEmployeeSales" and my subform is "RetailSalesSubform".
Here are some screen shots of what I'm trying to do:
EDIT: I figured it out. I was making it TOO COMPLICATED!
I kept trying to enter stuff like "Forms!Yadda!Yadda" but all I needed to enter was the subform control's name only into the Requery "Control Name" field on my screen shot above. Imagine that! Here is a screenshot on how to determine the subform control's name (for other loser noobs like me):
There are two parts to a subform, the subform control and the form contained. It is important to use the name of the subform control to requery, not the name of the form contained. So:
Forms!MyMainForm!MySubformControlName.Form.Requery
Or when writing code in the form module:
Me.MySubformControlName.Form.Requery
An advatage of using Me in the form module is that intellisense will give you the name of the subform control.
More information: http://access.mvps.org/access/forms/frm0031.htm
The macro is one way to do it. VBA can also do this. In your case in the "onclick" event you could put the code:
Docmd.Requery "ServiceSalesSubform"
It does the same thing but sometimes it is nice to have everyting in VBA code. When there is a mix of code and macros it can get confusing to tell what is happening and when.