In my database, I have entered a query page in Design View, and entered the following two headers in separate columns:
MonthsSince: DateDiff("m",[LastContact],Now())
LastContactError: DateDiff("m",[LastContact],Now())
The criteria I'd like to set are: ">6" and "<0"
The >6 criteria filters results so that the user knows that it has been six months since the person in question has been contacted
THe <0 criteria show erroneous dates, specifically if a user put the LastContact date as being in the future
The problem I'm having is that Microsoft Access 2010 merges these two criteria into the rightmost field (LastContactError), and thus no results are returned (there are no numbers >6 and <0).
Even with just the >6 criteria in the MonthsSince field, after one successful search this criterion is moved to the LastContactError field.
Edit 1:
I tried putting on criterion in the "criteria" row, and one in the "or" row, and got the same problem.
Edit 2:
I realised that this single query checks that both the conditions are met, not that either of them are met! The same thing is being compared: LastContact and Now().
Solution:
Create two queries, with separate criteria
Solution: Create two queries, with separate criteria.
Currently, this single query is trying to meet both criteria - which are based off the same comparison. Obviously, it fails.
Related
I haven't been able to make a DLookUp function work in an Access report. I can't figure out what I'm doing wrong.
The report is getting its dataset from a query called Aggregate Query. This query builds a dataset from 20 related tables using CustomerID as the primary key in one table and as a foreign key in the other 19. CustomerID is specified by an open Form with the desired customer's record displayed, including the CustomerID field.
This means Aggregate Query has several rows for one specific CustomerID. One field, Needs Notes, will have the same content on every row. What I'm having trouble with is getting only one of these rows displayed in the subreport, and subsequently on the parent report.
If there are six rows, say, in Aggregate Query, then the same Needs Notes field is repeated six times. I want it to appear only once in the subreport.
I couldn't choose only the first row from Aggregate Query. If this can be done that'd be great. I don't know.
So I created another query, Need-notes Only Query, which always gives me only one row every time. So far so good. Now I want the contents of the Needs Notes field to appear all by itself in the subreport. To do this I selected the text box and entered the following into the Control Source parameter:
=DLookUp("[Needs-notes Only Query]![Needs Notes]","Needs-notes Only Query")
No dice. I get six rows saying #Error.
Is there a way I can get just one row of the Needs Notes field into my report?
Split field and table names:
=DLookUp("[Needs Notes]","[Needs-notes Only Query]")
I have 6 Datasets each one is the same query but has a different WHERE clause based on employee type. They generate 6 tables. At the top of the report there is a summary table which uses reportitems!textboxXX.value to grab the totals for 2 particular fields from all the tables. I'm also using a StartDate and EndDate parameter. Each reportitems! expression in the table comes from a different dataset in the report if that is relevant.
When I run the report using dates from yesterday back to the 9th of May I get the desired output.
But when I go to the 8th I get multiple rows all the same.
and as I go even further back I get even more rows of the same information. To my knowledge nothing interesting or different happened on the 8th of May and the tables further down the report look exactly the same. Any idea what might be causing this? The design view looks like this if that helps. There's no grouping or filters on the table.
Still not certain about the mechanics behind this but I found a 'solution' so I figured I'd post it. I just made a new dataset for my summary tables where the query was simply SELECT 1. Now I get a single row every time.
My company keeps records of job codes & purchase order numbers as machines are used, etc. I am trying to create a form where an individual can populate a job number and then input the time a machine was used (machine name and hours) for that job along with a few other fields. My primary question is if there is a way to populate one job code for multiple machines/hours. This would eventually be used for employee time keeping also.
You can do this by creating an update query.
See Create and run an update query or Update Queries in Microsoft Access
Not sure much of a newbie you are, but here's what I would do from start to finish.
1) Create an update query by going to Create -> Query Design.
2) Add your table to the query
3) In the upper-left part of the screen, "select" will be selected. Click on "update" to create an update query
4) In your query criteria, add whatever criteria you need to make it apply to multiple machines or hours. For example machines that have worked between January 1, 2017 and June 1, 2017 you would add (you need #'s for dates in queries)
=#1/1/2017# And <=#6/1/2017#
to your date field. Or let's say you have three machines named A1, B2, and C3. You only want to apply to job code to A1 and B2. Under the field that denotes your machine name your criteria would be:
"A1" or "B2"
Whether you use the date or machine field, you'll need to use the update query to input the job code for all applicable cases. let's say you want to make the job code "Code124" for all people who meet the criteria you specified. Under the Update to line in your query, type in "Code124" and hit "Run" (the icon in the upper left corner with an explanation point. That should do it.
I have a form that has multiple comboboxes. Some of them allow multiple values and some of them don't. One of the comboboxes that allows multiple values is causing duplicate entries in the form records.
I can't find any differences in the property sheet between the combobox that isn't working and those that are.
Example fields in the form:
Patient Account Number
Date of Admission
Location of Patient (combobox that allows multiple values; working correctly)
Interface Used (combobox that allows multiple values; working correctly)
Interventions (combobox that allows multiple values; NOT working correctly)
When I select more than one Intervention it duplicates the record within the form. I have 5 patients entered into the form, but one of them has 3 Interventions selected. So instead of showing "1 of 5" records at the bottom of my form I see "1 of 8" and 3 of them are exactly the same. When I look at my parent table though, there are still only 5 records.
Please forgive me if I didn't call something the proper name. I'm very new to Access. Thank you! I tried to add screenshots, but I don't have enough reputation points.
I suspect that the form's underlying query (=RecordSource) is using the Value property of the multivalue field. If so, remove Value from the query.
view the query's SQL and look for the word .Value
remove the word Value and the period before it then re-run the query the results will change back to normal amount of records and so will your form or report.
I have two tables and from that I am generating a query. I have columns in my query with field type yes/no. These are basically columns to determine the race of a person. The user enters information in yes/no for various races. I want another calculated column in the query which checks for all other race columns and calculates values in it.
I have to check for a few conditions in for the values in columns
For example:
1) If Hispanic is chosen, the new column should say hispanic(no matter what other options are selected. This is like a trump card)
2) If more than one is selected, then new column entry should say "multi"
3) If none of the options are selected, it should say "unknown"
4) If exactly one of them is selected, then that race should be displayed
Can anyone help me with this? I am new to Access
I can't code it for you but I can point you in the right direction. What you want to do is take all the tests you explained above and put them in a coded format :
iif ( condition, value_if_true, value_if_false )
Since you have a lot of possible outputs i'd use something like a Case Statement where you can test for all the possibilities.
Follow this link if you need any info on how to code both type of statements (iif and case).
Once you have tried something like this, you can comeback with a specific question if you encountered a problem in the process.
Good luck with your database.