I have a form in form view with a continuous subform in it.
I have a conditional statement in the conditional formatting for the control in question (which is a combo box) on that continuous subform. This conditional, when evaluates true, disables the combo control for that record:
[Forms]![frmCommuteInSub]![ctlDate]<getStartDate()
I have also tried this statement:
[Forms]![frmCommuteInSub]![ctlDate]<#12/01/2016#
Interestingly, this does not work in the main form... but if I open the subform by itself this formatting works just fine.
Anyone have an idea of what may cause this? I really need this to work in the main form.
PS. I'm using Access 2013. I am proficient in VBA or any other language if that helps.
Try using the DateDiff function and see if that works.
If DateDiff("d",[Forms]![frmCommuteInSub]![ctlDate],getStartDate()) > 1 then
The way I see it you have 2 options, it just depends on which suits you and your project.
Complete the conditional format based on a main form / subform relationship using the expression builder.
Complete the conditional format based using single value evaluation. However, in order to do this you will need to make sure the value you are evaluating is part of the table or more likely query you have the form b
Whichever route you choose, make sure to ensure that the variables or controls you are evaluating are producing correctly formatted results. That's half the battle!
More info:
http://www.iaccessworld.com/conditional-formatting-for-subform-or-datasheet-form/
https://bytes.com/topic/access/insights/868555-demo-conditional-format-subform-unlimited-colours
Related
I drag an drop a simple query without any criteria in a form.
I want to filter data (like FamilyName) via textbox in form through OnChange event.
Here the question: how can i filter query data with value of textbox?
If your query now appears as a subform in your form, use the MasterLinkFields and ChildLinkFields properties of that subform control:
As MasterLinkFields: [NameOfYourTextbox]
As ChildLinkFields: [NameOfFieldInQueryToFilterWithValueOfYourTextbox]
ON the After Update event of the textbox, you can set the record/row source of the query and/or subsform. You'll have to use vba to do this, but its a relatively simple task. Without any examples I can only give you the high level answer.
I have encountered issues with using "filtering menus" in report during development of database aplication for my employer.
For my filtering options I created buttons with OnClick Event:
DoCmd.GoToControl "MyReportField"
DoCmd.RunCommand acCmdFilterMenu
These buttons are embedded in subreport. Initial thought was to create buttons, similar to the one in ribbon, with filtering options (in final stages of development I am planning to disable/hide Access ribbon for users). I created 5 buttons, 3 for fields with data type Text, 1 with data type Date and 1 with Boolean data type.
To quote a classic, the buttons "are misbehaving." When I test their function in form in form view, the "BooleanFilterBtn" on click already doesn't display Yes/No options (or something similar), but displays 2 numeric values (like -24441 or -29696). And filter is not working whatsoever.
Another problem arises when I try to have active more than one filter at a time. Date field filter and one of the Text field filters are working when combined with another filter option. But after using one of the two remaining Text field filters, when I click any other of the filtering buttons, the FilterMenu becomes blank.
Worth noting is that right-clicking on given field in report works without issues, but not the way I want.
Given these rather odd behaviours I think I am missing something. Is there a way how to make FilterMenus work the way as familiar from the ribbon? If not, is there any other option with similar design, options that I could try out?
Additional info:
Subreport is connected with form through "MyIDField." Both subreport and form have query data source, already saved.
All field names and data types are matching.
EDIT: Also I should have written that the FilterBtns doesn't work if I open the subreport separately, they work only when I open form (with subreport in it), eventhough the FilterBtns are using only controls from the report.
EDIT2: Code behind filter button filtering Boolean data type (boolean data are in Report in form of Yes/No check-fields, as mentioned in June7 comment bellow):
Private Sub btn_FiltrGarant_Click()
DoCmd.GoToControl "Garant"
DoCmd.RunCommand acCmdFilterMenu
End Sub
When I change this code to:
Private Sub btn_FiltrGarant_Click()
Me.Garant.SetFocus
DoCmd.RunCommand acCmdFilterMenu
End Sub
Brings no effect, only that the loading time of actual FilterMenu takes a bit longer.
Example for Text data type field:
Private Sub btn_FiltrRzh_Click()
DoCmd.GoToControl "ZkracenyNazev"
DoCmd.RunCommand acCmdFilterMenu
End Sub
Changing code in the same manner:
Private Sub btn_FiltrRzh_Click()
Me.ZkracenyNazev.SetFocus
DoCmd.RunCommand acCmdFilterMenu
End Sub
Brings no effect too.
May it be that the FilterMenu is not meant to/available to be used in reports? Or may it be disabled in default settings of Access?
Because also the situation, that if I open the Report separately (not in form as a subreport, but just as report by itself in report view), using any of the FilterBtns gives me RunTime error 2046, that the action GoToControl is not available. Changing to SetFocus eliminates the error, but the button doesn't bring up any FilterMenu at all. But these issues are valid only if I open report separately (which is not my interest), but might be helpfull as information.
Right now, I don't know where the problem could be. Anything I could think of was data type/naming mismatch, but that's not the case.
FINAL EDIT: After almost a month (there were holydays) of trying and searching for a way how to make this setup work I decided to switch from subreport to subform, in which I will try to obtain the same functionality.
Maybe just reports are not supposed to be handled the way I wanted to.
Just out of courtesy I am putting June7 answer as verifiedfor the time spent on helping me.
Thank you.
Don't know why your yes/no field displays 2 numeric values like -24441 or -29696 in the filter menu. Regardless, not able to get the filter menu to act on a yes/no field at all. However, get around that with an expression in report RecordSource query that changes the Yes/No field from Boolean to text values and use the calculated field in report design, like:
SELECT *, IIf([fieldname], "Yes", "No") AS IsSomethingTrue FROM tablename;
Use Me.controlname.SetFocus instead of GoToControl so the report will open independently or as a sub object.
You have to be careful how you refer to a Report object that is within a subForm container. They do not behave the same as subforms in many ways.
Even a simple refresh is actually difficult to achieve, as reports are not meant to be dynamic like a form.
To refer to it in VBA you have to use the full form syntax;
[Forms]![MainFormName].[Form]![subReportHolderName].Requery
Using the normal Me.blah.blah reference will not work with a form embedded report. Note that you refer to the container - NOT the report object.
I am looking at the following post SO Question and am struggling with how to perform the answer to the question:
The way that I ended up solving this was to add a field to T, and have that field updated during the AfterUpdate() event with the value from the DLookup() call. Because the field is now no longer query-based, it can be used to filter the form.
Specifically, what are the steps to update the 'table field' with the value from the DLookup() call? Do I place the DLookup in VB code?
I always prefer using vb codes but that is because I don't feel as flexible in the things I want to accomplish using macros. However, if you don't want to use VB code you can create a bound text box that captures the value of the unbound DLookup. then have the bound text box set to visible = false. that way you will not have two box with the same information on your form.
I am working on a complicated project in MS Access 2007.
I am having some difficulty finding the correct method/Syntax for having a query outside of the open form be requeried. I am still fairly new at the VBA so forgive me if I make mistake or I am incorrect.
I have created a query which uses the value of a particular Combo Box in my form as part of its WHERE criteria. I have tested that and it works just fine. Now I am working on an "After Update" event for the Combo Box in question so that When I change the value of that Combo Box in question it will automatically tell my query to rerun itself with the new value in the WHERE Clause.
I was originally thinking of using the following command in VBA
DoCmd.Requery [Queries]![TestQuery]
But I am unclear on if I can use the DoCmd.Requery since the query is outside of the open form and not imbedded into it.
I am looking for options on how best to accomplish this effect, Not Strictly VBA Only. So if a Macro would work better please give me an example to work from
UPDATE
Just to make things a little clearer Here is the actual SQL Code for the Select Query that I want to requery through this after Update event.
SELECT ForcastTrans.Location, ForcastTrans.Client, ForcastTrans.Department, ForcastTrans.Account, ForcastTrans.Currency, ForcastTrans.Month1, ForcastTrans.Month2, ForcastTrans.Month3, ForcastTrans.Month4, ForcastTrans.Month5, ForcastTrans.Month6, ForcastTrans.Month7, ForcastTrans.Month8, ForcastTrans.Month9, ForcastTrans.Month10, ForcastTrans.Month11, ForcastTrans.Month12
FROM ForcastTrans
WHERE (((ForcastTrans.EntityID)=[Forms]![ReportSelect]![BusinessUnit]));
As I said before this Query works just fine by itself I just need to be able to issue an after update event which will tell this query to Rerun based on the updated WHERE criteria.
Danke.
It still matters how you're building the report. I would assume that this query is the record source for the report and that the report is only generated when you request it from this very form you're updating. In which case, the query should automatically take the updated value when you load the report; If you're looking to generate the report after you close the form, then the query won't work once the combobox is destroyed. I'm still speculating on what exactly you want to do here, but suffice it to say, I don't recommend having a stored query that depends on an object in a form.
A cleaner way of doing this is to use a WhereCondition in your OpenReport call:
(inside a button click on ReportSelect)
DoCmd.OpenReport "YourReportName", acViewPreview,,"EntityID=" & Me.BusinessUnit
This opens your report filtered by the form that opens it, but still allows the report to open showing all of the data when the form is closed.
Kevin
I'm trying to display the sum of a field in a text box in the form footer. The field is not calculated in any way.
Here are a couple of the things I've tried:
=Sum([txtWeldInches])
=Sum([WeldInches])
=Sum(CDbl([txtWeldInches]))
=Sum(CDbl([WeldInches]))
...well you get the idea. Each iteration I've used results in the Text Box displaying #Error Without exception.
I've used similar constructs in different forms in the same project, so I'm not sure what the problem might be.
Has anyone run into this before?
EDIT:
I ended up writing a VBA routine to update the boxes when it was likely that they would be changed rather than trying to get a bound sum() function to work.
http://support.microsoft.com/kb/199355
All of the domain functions are based on the same query (over the underlying recordset). If one of the bound functions on the form has a binding error, all of the functions on the form will return an error.
In other words, make sure all your footer controls are resolving properly and not hitting any nulls.
If you use a SUM or AVG then make sure you are also using the Nz function:
ControlSource = =SUM(NZ([FIELD],0))
Is the field "WeldInches" existing in the data source for this form?
What datatype the field "WeldInches" is?
EDIT: I have looked at all your comments. If it doesn't work by databinding, try and use the unbounded way. At runtime, get the value of WeldInches using DSUM and set the footer textbox's value when the form loads.
Also, remember to update it at places where you think the SUM could change.
I had the same problem as Rister.
The source of the form was an underlying query.
I had a bound text box named txtQty on this form. Its control source was Qty (based on the underlying query of the form).
I created an unbound text box and entered =SUM([txtQty]) and received an error.
I tried various ways to find a solution and was very desperate.
Then I deleted the underlying query and created a new one using the same name and fields as before.
Then I entered =SUM([Qty]) into the unbound text box on the form and voila, it worked. Note that I didn't enter the name of the bound text box (txtQty) into the expression, but its control source (Qty). I don't know why, but it worked for me.
I know you said "Form" but for those who have issues with the Sum formula in an Access "Report" the formula has to be in the Report Footer NOT the Page footer. Took me a while to figure it out as Access defaults to only showing the page footer.
You want to sum by the name of the column in the record source: SUM([WeldInches])
Make sure there are no other textboxes with the name WeldInches.