Access Textbox control source outside current report - ms-access

I am creating a Report in MS Access 2016. I want textboxes showing a summary of data from other tables - without actually showing rows of those tables (no subreports if possible). For example, I have tried to create a textbox with formula
=Format(Avg([WeekData].[DIFOT]),"##0.0%") & " DIFOT This Week"
which should return something like
100% DIFOT This Week
(NB Weekdata is a query and DIFOT is a field in that query, all in the same database as this report.)
However instead it just gives me #Error.
Please can you tell me the most efficient way to pull together summary figures such as these without creating any more queries and/or subreports than absolutely necessary? I'm quite new to SQL and Access on the whole.
Many thanks in advance.

Use DAvg() domain aggregate function. Also, the ## characters in Format() pattern serve no purpose.
=Format(DAvg("DIFOT", "WeekData"), "0.0%") & " DIFOT This Week"
or
=Format(DAvg("DIFOT", "WeekData"), "Percent") & " DIFOT This Week"

Related

Expression in Textbox not passing value to the table

Obviously I am not an Access expert or I would not be asking this question. I created a small database with several tables. On a form, there are several combo boxes for the user to choose different combinations of medium, paper, sizes, etc. I have already created an expression that returns the correct value I need, but I cannot figure out how to get this value into the correct field on the table to store with the record the form is creating. Below are screen shots of the form and a couple of the tables. I have also included the expression I am using. I need the value that the expression returns to go into tbl1Artwork and populate the ArtWorkSKU field.
Expression:
=Left([PieceName],4) & [cbxArtist].Column & [cbxMedium].Column & [cbxPaperType].Column & [cbxPrintType].Column & [cbxSize].Column
The ArtWorkSKU text box is unbound as I had to type the expression in there. I am not sure if this is the correct way to accomplish the goal. In the tables below, except for the PK, all fields are Short Text.
All guidance is greatly appreciated.
Saving calculated data is usually not necessary and can be risky. Saved value can become 'out of sync' with raw data. Value can be calculated when needed.
Saving calculated data requires code (macro or VBA).
Can be as simple as Me!fieldname = Me.controlname.
Real trick is figuring out what event(s) to put code into. In your case, most likely form BeforeUpdate.
Advise not to use spaces nor punctuation/special characters (underscore only exception) in naming convention. Better would be ArtworkSKU or ArtworkSKUnum or Artwork_SKU_Num.
Create the following function in VBA:
Function UpdateSKU()
Me.ArtWorkSKU = Left(Me.[PieceName],4) & Me.[cbxArtist].Column(3) & _
Me.[cbxMedium].Column(2) & Me.[cbxPaperType].Column(2) & _
Me.[cbxPrintType].Column(2) & Me.[cbxSize].Column(2)
End Function
Then, on the form, update the After Update event property (not vba) of each "feeder" control to:
After Update: =UpdateSKU()

MS Access Date Grouping is not working in report

I have created a simple Microsoft Access 2007 app of receiving and paying vouchers, everything is working properly but one thing that my mind doesn't solve.
I have created a report template of "Receiving Amount" where I want report be grouped in respect of receiving date. I have added a field named "Receiving Date" in "Group, Sort and Total" and when I generate it, it doesn't group the content in respect of date.
Adjust your Grouping and Sorting to use the expression:
Fix([Receiving Date])
I found the solution.
The reason of not grouping date wise because Access could not understand the date, like Gustav said, format is just for display but actual value is different and Sergey S said "If the field with date contains time. you won't be able to group the report".
Finally, I had to remove time from the date and keep it clear to Access so it can group my report.
=MonthName(DatePart("m",[receiving date])) & " " & Format$([receiving date],"d"", ""yyyy")
Where receiving date is the field name.

How to make sure that MS Access displays the correct subreport data of the current record?

I have a payslip main report with 3 subreports, all are linked through the employee's serialNumber:
rptPayslipPay -for displaying regular pay
rptPSDeds - for displaying deductions
rptPayslipOpay - for displaying supplementary payments. This
subreport is only showed for few selected employees.
I was able to show the total amounts of the 3 subreports on my main report's page footer. Since my last subreport rptPayslipOpay, may or may not have any data, I am displaying it in a text box named [txtOpay] like this:
=IIf([rptPayslipOPay].[Report].[HasData],[rptPayslipOPay].[Report]![sumOpay],"")
My problem is,the value of [txtOpay] shows even if the page has moved on to another employee, thus displaying the previous employee's supplementary payments to the next employee.
Is there a way to prevent this from happening?
Thank you very much.
You might be able to get it to work by fiddling around with the subreports, but assuming a 1:1 relationship between top-level report and subreport, and assuming serialNumber is a string; instead of your IIf statement, you might consider trying something along the lines of:
=DLookup("sumOpay", [rptPayslipOPay].Report.RecordSource, "serialNumber='" & [serialNumber] & "'")
I'm not sure exactly how your objects are named, but I think this should be close to what you're looking for.
By your description, it sounds like "sumOpay" might be a calculated field in the rptPayslipOPay report. If so, you can use:
=DSum("<field containing data to sum>", [rptPayslipOPay].Report.RecordSource, "serialNumber='" & [serialNumber] & "'")
Granted, these will run more slowly, but this might be an easier way to get it to work.
Another option is to left-join rptPayslipOPay's data from in your top-level query, and sum it.

Access 2003: Conditional formatting based on table

I have a MS Access 2003 CRM system that sets follow up actions. I need this to use conditional formatting to ensure I don't select a weekend date or something like a bank holiday / annual leave.
I've tried conditional formatting the next action date with the following expression suggested by the designer:
DLookup(“[OffDates]”, “[tblOffDates]”, “[OffDates]=#” & [the form control name] & “#”)
However this isn't working. See links below for some context:
http://i.imgur.com/VVgExW1.jpg
http://i.imgur.com/gpXRWCT.jpg
I thought it would be simpler to just have it flag up when it matches a date but it's not working. Any ideas?
Thanks in advance.

Crystal Reports & Access 2013 - Continuous Form?

Original Question
In Crystal Reports 2011, how do I show all values from a certain Field?
My formula that pulls the data from an Access DB is simply:
{tblQuoteFormSub_Windows.fQty} & " - " &
{tblQuoteFormSub_Windows.fWindowSizeW} &
" x " & {tblQuoteFormSub_Windows.fWindowSizeH}
If I right click on the field in Design or Preview Mode, I can select "Browse Field Data, and see all the values, but I cannot figure out how to print all of them.
EDIT:
I used a sub report (I am still learning, and didn't know they existed in CR until today). Now I can view the records I need based on the fJobID Field.
However...
I need a way to select which group to print... Preferably by using a control in Access to select a Job #. Should I post that as a new question?
The subreport is a good idea. I was thinking of suggesting that, but I wasn't sure if it would have met your needs. I haven't tried Access 2013 yet, and it's been awhile since I've even seen CR. But as for your other question, I can give you one suggestion that I used with previous versions.
In your Access query, add a parameter to your query, i.e. Select * from mytable where job='[Enter Job Num]'. Then when you preview your CR, that parameter should filter through so that it will ask you for the job number when you preview it.
Give it a try and let me know if it worked.