I'm trying to pull some data from a query in my database into a calculated field in a table. I have dates entered for some jobs I'm recording (DateCallOpened, DateQuoteSent, DateQuoteReceived), as well as WorkType for each job to track the type of work done. I've used calculated fields to find the time it took for each record between those dates. I've also used qryTimings to find the average length of time for the WorkType.
I'd like to build fields that showed the ProjectedQuoteSent, and use the data from my query to calculate the date I can expect the quote to be sent, but I just can't figure out how to pull that data out of the query. I was hoping it would be something as simple as:
=[DateCallOpened]+[qryTimings]:[Avg Of TimeToSendQuote]
You can use a DLookup() function to grab your value from your query. So your formula would be something like:
=[DateCallOpened]+DLookup("Avg Of TimeToSendQuote", "qryTimings", _
"[WorkType]=" & [Forms]![frmMyForm]![txtWorkTypeInput])
See this for more info.
Related
Pic hereI am new to MS Access. I have a customer table with creationdate field as well as submissiondate. The submissiondate was calculated via a query since it carries multiple conditions. I created a form from the customer table where I am able to input the creationdate field and I managed to show the submissiondate (from the query) via Dlookup but the date is not recorded in the customer table. How can I record the submissiondate value from the query in the customer table without having to do an update query every time I add a new customer? I did an update query but it updates all records every time it runs, and we have more than 50K customers. Any help is appreciated.
this is the query in Access that gets the result for me.
SELECT HardDeadlineCalculationQ1.ID, HardDeadlineCalculationQ1.R AS ReferralDate, HardDeadlineCalculationQ1.[Source of Referral], HardDeadlineCalculationQ1.HD1, HardDeadlineCalculationQ1.wdhd1, HardDeadlineCalculationQ1.hd2, HardDeadlineCalculationQ1.wdhd2, HolidaysT.holidaydates, Switch([HardDeadlineCalculationQ1].hd2=holidayst.holidaydates,"Yes") AS isholiday, IIf(isholiday="Yes",([HardDeadlineCalculationQ1.hd2]-1),[HardDeadlineCalculationQ1].hd2) AS hd3, WeekdayName(Weekday(hd3)) AS wdhd3, Switch(WeekdayName(Weekday(hd3))="Monday",(hd3),WeekdayName(Weekday(hd3))="Tuesday",(hd3),WeekdayName(Weekday(hd3))="Wednesday",(hd3),WeekdayName(Weekday(hd3))="Thursday",(hd3),WeekdayName(Weekday(hd3))="Friday",(hd3),WeekdayName(Weekday(hd3))="Sunday",(hd3-2)) AS hd4, WeekdayName(Weekday(hd4)) AS wdhd4
FROM HardDeadlineCalculationQ1 LEFT JOIN HolidaysT ON HardDeadlineCalculationQ1.hd2 = HolidaysT.holidaydates;
regards,
"The submissiondate was calculated via a query since it carries multiple conditions"
By this, i presume you mean that the submission date is a calculated field(as its control source)
Do the following
Copy the calculation, i.e formula and put in vba code, under the after update event of every field that is a variable in the expression.
e.g submissiondate= place the formular here
Then on the form remove the calculation , i.e formula from the control source of the form control and make a field in the table the control source, e.g submissiondate.
I'm new to Access and I'm building a database here at work to log all production that was done. I was able to make a query form with criteria between a date range, condition, part number and work order. Using a code in the expression builder, these are what is placed in the criterion:
Date range: Between [Forms]![Form Query]![BeginDate] And [Forms]![Form Query]![EndDate]
Part number: Like (IIf(IsNull([Forms]![Form Query]![Part Number]),"*",[Forms]![Form Query]![Part Number]))
Condition: Like (IIf(IsNull([Forms]![Form Query]![Condition]),"*",[Forms]![Form Query]![Condition]))
This is where even when part numbers and condition is empty, the query will display all records. My problem is the date range if I leave it empty (say, I simply wanted to query all of the records), it will return with zero value. I wanted it to make it simple for the user that if I leave the date range empty, it will still show all of the records. I had to temporarily put the date range as required to always return results.
Query form
Query Criteria
All input is appreciated! Thank you so much!
Provide alternate value if date is not input:
Between Nz([Forms]![Form Query]![BeginDate], #1/1/1900#) And Nz([Forms]![Form Query]![EndDate], #12/31/2200#)
For text fields, assuming value is unique and is never part of a longer string, LIKE criteria can just concatenate wildcard:
LIKE [Forms]![Form Query]![Part Number]) & "*"
I'm an ms access novice and i'm in the process of building a simple relational database. I have two tables, one containing a date field and another table containing a range for the dates and the value i want to return based on the date range. In excel i would use the LOOKUP function but in access, the only options seems to be to use the "DLookup" function.
the destination table has a column with the dates. So far, the expression that i've got which keeps returning an error is
DLookup(DLookUp([KR_DB]![DPL_TargetMonth],[SeasonFY],[KR_DB]![DPL_TargetMonth] Between [SeasonFY]![SeasonDateFrom] And [SeasonFY]![SeasonDateTo])
I don't know how to write the proper syntax for this.
Saving the SeasonFY ID as foreign key in KR_DB would be the relational approach. However, DLookup could be like:
SELECT KR_DB.*,
DLookup("Season", "SeasonFY", "#" & [DPL_TargetMonth] & "# BETWEEN SeasonDateFrom AND SeasonDateTo") AS Season
FROM KR_DB;
I have an ACCESS database that has a table with date as one of the fields. I can create a form that allows the user to enter a start date and end date and then use those in a query to filter the date for only records between those dates. But I would like to make the end date optional so if the user would only enter the start date the query would return on records greater than that date. I am trying to do this with one query and without getting into VBA but not sure if this can be done.
I tried something like this but it did not work...I got error message saying the syntax was not correct or I got no results at all.
In the date field criteria I tried
IIF(isNull([Forms]![frmdateselect]![enddate]),
(>=DateValue([Forms]![frmdateselect]![startdate])),
((>=DateValue([Forms]![frmdateselect]![startdate])) AND
(<=DateValue([Forms]![frmdateselect]![enddate]))))
Any help would be great
Have you tried replacing the IsNUll with the Nz function?
IIF(Nz([Forms]![frmdateselect]![enddate]),0),
([Forms]![frmdateselect]! [enddate]),
(>=DateValue([Forms]![frmdateselect]![startdate])),
((>=DateValue([Forms]![frmdateselect]![startdate])) AND
(<=DateValue([Forms]![frmdateselect]![enddate]))))
I've just started using MS Access this month and I have a very odd bug. I'm trying to create a query that searches for records in a table that have a maxBenefit (a dsum from a different table's field, with a one to many relationship) within a certain range. I'm using the DSUM function to get the maxBenefit because the table has a dailyBenefits field that need to be added together.
Here is my function:
maxBenefitOfQuote: Nz(DSum("[wholeYearBenefit]","tblDisabilityQuoteDailyBenefits",
"[quoteID] = " & [tblDisabilityQuotes].[ID]))
I know the function works because it produces the correct values. The query also takes in two parameters from a form to create a range for maxBenefits.
I limit the results with this criteria:
>=[Forms]![frmDisabilityFindSimilarQuotes]![minBenefitTotal] And
<=[Forms]![frmDisabilityFindSimilarQuotes]![maxBenefitTotal]
The problem is I get very odd results from the query with maxBenefits outside the range or not returning records with maxBenefits inside the range. If I set the minBenefitTotal to 0 and the max BenefitTotal to 100000000 I get no records returned from the query. If I set the minBenefitTotal to 0 and the maxBenefitTotal to 999999999 I get all the proper records.
Any ideas why this is happening? Thanks in advanced.
First,
Try wrapping both of your inputs in a call to CCur:
>=CCur([Forms]![frmDisabilityFindSimilarQuotes]![minBenefitTotal]) And
<=CCur([Forms]![frmDisabilityFindSimilarQuotes]![maxBenefitTotal])
Next,
If you omit the actual form inputs, and hard-code numbers into the criteria, does it work?
For Example: (>= 0 and <= 100000000)
If that worked... It feels like a string -> number conversion issue. Make sure all string input is actually a number (via CCur()) before sending it into the query.