Query Needed To Return Last, Or Next To Last, Value Based On Date...

Apr 23, 2007

I have the following tables: Rates and SelectedDates, which are structured as follows.

Rates: RateID, EffectiveDate, Rate
SelectedDates: Date. Table is bound to a combobox in which user selects one or more dates, mm/dd/yyyy, which is the same format as Rates.EffectiveDate.

I need a query to return the first Rates.Rate for the following conditions. (there will be a minimum of one record in the Rates table)

IF there is only one Rates.EffectiveDate for the SelectedDates.Date
return the associated Rates.Rate

ELSE IF count(Rates.EffectiveDate <= SelectedDates.Date)>=1
return the first Rates.Rate where Rates.EffectiveDate <= SelectedDates.Date

ELSE
return Rates.Rate associated to the Rates.EffectiveDate closest to the SelectedDates.Date.


I hope this is clear, as it is late and I am tired...:confused:

Thanks in advance,
Rod

View Replies


ADVERTISEMENT

Forms :: Return Records From One Table Based On Date In Another

Jul 24, 2013

When I add a record to table A (using a form) the first field I enter is a date. That date will then determine which records I see in my drop down list from table B (via a query).

Some records in table B have EffectiveFrom and EffectiveTo dates recorded - because they are now obsolete, other records have no dates recorded in these fields because they active.

How can I view and then select from the drop down only those records in table B which are effective/valid to the date entered in table A?

View 1 Replies View Related

Queries :: Return Records Between Dates Based On 2 Date Fields In A Table

Apr 24, 2013

I have a table which includes a start date field and completion date field for housebuilding.

I am trying to extract all records that have either a started date or a completed date between 2 dates supplied by the user. I have tried to use Between on both fields but that doesn't return results between the fields.

It workd if I just do it on EITHER the start date field OR the completion date field so that implies to me that I need to break it into 2 queries, one returning start date recrods and the other returning completion date records but then I would need to have somthing that removes records that appear in both the start date and the completion date results.

View 7 Replies View Related

Queries :: Date / Time Query - Return All Records Of Specified Date Or Date Range

Aug 19, 2015

I have a table that has entries recorded with date and time in one field, and I want to have a query that returns all records of a specified date or date range, regardless of the time in the field.

I have tried

Code:
Between [StartDate:] And [EndDate:]

And

Code:
Between [StartDate:] & "00:00" And [EndDate:] & "23:59"

Neither of which work ....

View 13 Replies View Related

Help Needed With Date Query!

Feb 27, 2006

Hi all,

I've searched the forums but can't seem to find anything similar. I work for social services and we have a database that stores information on children who may need services from adults when they reach 18.

What I need to do is create a query (so that a report can be run) that will show those children who will turn 18 during the year Apr 1st - Mar 31st but I'm not sure where to start. Can anyone offer any pointers please?

The fields within the database are:
Client ID, Name, Surname, Date of Birth, Address

Many thanks

View 3 Replies View Related

Help Needed On Up-date Query!

Apr 11, 2007

i am trying to update a field within a table. But i dont want to update the whole of the data within the field just one part of it.

The field is the Tutor Group for students in the format 7B, 7D, 7F, 7H, 7M, 7S, 8B, 8D, 8F,... etc where the number represents the year group! i want to use an expression that would add(+) 1 to the year group but leave the letter the same as this doesn change. By doing this the above list would change to 8B, 8D, 8F, 8H, 8M, 8S, 9B, 9D, 9F, ...etc

I attempted to use the following expression: ((*)+1)(*) but it didn't work.

I should have had the year groups separate but i am given an Excel flat file which has details of the students and doesnt separate the the two.

any help would be much appreciated! hope someone can help!

View 5 Replies View Related

Form And Query To Return Records Between Certain Date Range

Oct 15, 2013

First, I am trying to get a query to return records between a certain date range. In the form I have DateFrom and DateTo unbound text boxes from which faculty select the date range. I know I have done this before, but I cant figure out how to create a field name and write the criteria for the source query in design mode!

I tried [Form]![FormName]![DateFrom]<[Form]![FormName]![DateTo] in the criteria but I can't seem to write a valid field name that doesn't alter the criteria in some way...

Second, in the same form, faculty enter the StudentID for the student they wish to get records for. How do I write the code to show a msgbox when there is no such ID in the event they enter an StudentID incorrectly.

View 1 Replies View Related

Help Needed Please: Date Parameter In Query - Leaving Blank To Include All Records??

Aug 9, 2007

Hi

Bit of an Access beginner and am trying to sort something out for work - not sure why they've asked me!

I've created a query to search on a couple of items using drop down boxes on a search form I created. This bit of it works fine, I used this site http://www.fontstuff.com/access/acctut08.htm and copied what he had done. This is fine.

I now want to add a date search to the same query. I know I can use Between [..] AND [..] but if I leave the boxes blank it finds no records. I'd like it to search and include all.
Ideally I want to include 2 extra text boxes on my form that I can put a to and from date in (or not put a date in and it find everything).

Hope that makes sense, please can someone do me an idiots guide?

Many thanks
Phil

View 5 Replies View Related

Queries :: Date Range Query - Return Lines Where Field Is Blank In Table

Aug 15, 2013

I have a single table with customer information, one of the fields is a date field "LastContacted".

I'm creating a search form with 2 date fields (txtDate1 & txtDate2) to search a date range of the LastContacted field, and I need to write this into the query that the search form uses.

I have written this using Nz so that it can still return results if the search boxes are left blank:

Between Nz([Forms]![frm_AdvancedSearch]![txtDate1],#01/01/1989#) And Nz([Forms]![frm_AdvancedSearch]![txtDate2],#01/01/2999#)

This seems to work and it returns lines from the table where there is a date entered. However some of the fields in the table have no entry in the LastContacted field. How to code this query so that it also returns lines where the LastContacted field is blank in the table?

I have tried:

like "*" & (Between Nz([Forms]![frm_AdvancedSearch]![txtDate1],#01/01/1989#) And Nz([Forms]![frm_AdvancedSearch]![txtDate2],#01/01/2999#)) & "*"

but this returns errors when I try to run it.

I'm using Access 2010.

View 14 Replies View Related

Modules & VBA :: Return Rows In Query From Variant Array Return From UDF

Sep 16, 2014

I have a simple UDF that takes a string and returns a variant, which is an array of strings Example Input "Brick Wall" Return value would be a variant array with first element "Brick" and and second element "Wall" Now I have a table with a field of strings, and I want to make a query that returns all the results from the function, one per line.

So if my input table looks like this

[strField]
"kick the ball"
"return the pass"

my query result should looks like this

[Orig] [new]
"kick the ball" "kick"
"kick the ball" "the"
"kick the ball" "ball"
"return the pass" "return"
"return the pass" "the"
"return the pass" "pass"

Last time I had to do something like this I used VBA exclusively, with ADO objects, but I thought a query based solution would be easier.

With my current data the largest return array size my function returns is 27 elements but I wouldn't want to rely on that number being fixed.

View 3 Replies View Related

Queries :: When Date Null Return Today's Date

Aug 8, 2013

I have a query where I display the [OPEN DATE] and [CLOSE DATE] of my cases. However, when I run this query sometimes the cases are not closed yet, therefore there are null values. However, I also have a field to calculate the datediff between these two dates. I need the [CLOSE DATE] field to display today's date when it is a null value so that I can still get a count of the days using datediff when I run the query.

View 1 Replies View Related

Text Return Based On GPA

Nov 10, 2004

Dear All:

Thank you for all you help with the above title. Your suggestions were all implemented.

Code:
Private Sub GPA_AfterUpdate()
If DIVISION = GRADUATE Then 'Honors field is empty
HONORS = ""
End If
If UNDERGRADUATE = True Then 'Apply appropriate honors
End If
If GPA < 3.2 Then
HONORS = ""
ElseIf GPA >= 3.2 And GPA < 3.5 Then
HONORS = "CUM LAUDE"
ElseIf GPA >= 3.5 And GPA < 3.8 Then
HONORS = "MAGNA CUM LAUDE"
ElseIf GPA >= 3.8 Then
HONORS = "SUMMA CUM LAUDE"
End If
End Sub

Here is the issue: Form created with with a combo box called "DIVISION."The choices of the combo box are "GRADUATE" AND "UNDERGRADUATE." There is a text box called "GPA", where a gpa is entered. then, there is an "Honors" field. When a gpa is entered, the honors box returns the appropriate message.

When graduate is selected from the combobox, the honors box should be empty. (That part does not work.) When undergraduate is selected from the combo box, it works.

Please help,

Dion

View 5 Replies View Related

Return Dates Based On Day And Month Only

Jan 3, 2006

I would like a query to return dates based upon the input of just the day and month. At the moment I have a parameter query which asks for 'start date' and 'end date' and this works fine, but I want the query to return all the records for all the years in the database and not just the current one (date format is dd/mm/yy)

So if I type <start date> 01/01 and <end date> 02/01 the query will return:

01/01/04
01/01/05
01/01/06
02/01/04
02/01/05
02/01/06

Does anyone know a solution - I have been searching all afternoon!!??

View 1 Replies View Related

Return Info Based On Other Fields

May 3, 2006

Hi All

I have 2 formulas that work for me in excel. I hope to be able to replicate the result in Access.

1)
I have the following in a field called PROBLEM STORE NAME:
SALE (DAY 1 - HD)
Mt DRUITT (WOWPOS) (E)
THE MALL (WOWPOS)
TOWN HALL (RF)
LIVINGSTON

I want these to be grouped as WOWPOS or ISS460 (if not WOWPOS), so return in field STORE TYPE as:
PROBLEM STORE NAME.............................STORE TYPE
SALE (DAY 1 - HD)............................................... ..ISS
Mt DRUITT (WOWPOS) (E)......................................WOWPOS
THE MALL (WOWPOS).......................................... ...WOWPOS
TOWN HALL (RF).............................................. ......ISS
LIVINGSTON........................................ ..................ISS
I use the following formula in Excel to achieve this when I export query results from Access:
=IF(ISNUMBER(SEARCH("wowpos",K2)),"WOW","ISS460")

2)
I have a field VENDOR ID that may or may not contain ANY detail. If the cell is empty I need it to return N/A. If populated I need to return VENDOR CALL. The following formula achieves that for me in Excel:
=IF(ISBLANK(X2),"NO","VENDOR CALL")

Any suggestions would be greatly appreciated

cheers

sallee

View 1 Replies View Related

Honors Text Return Based On GPA

Nov 9, 2004

Dear Access Wizards:

I have created a form based on a query with students' gpa in the form. The gpa is in a specific field.
There is another field for honors with is for summa cum laude, magna cum laude, cum laude.

Here is the issue: If the students' gpa is 3.8, return "summa cum laude"
If the students' gpa is 3.5, return "magna cum laude"
if the students' gpa is 3.2, return "cum laude"

This applies to undergraduate students only, which there is a field for.

Any ideas on how to resolve this issue?

Many thanks,

Dion

View 3 Replies View Related

General :: How To Return A Value Based On Another With Subforms

Mar 14, 2015

I have a form with a field within it called ID number, another table contains the ID number with a person's name next to it. I was wondering how I can make it so that in the form, when the ID number is entered, the name of the person also shows next to it and does so automatically for each different record. I am pretty sure that a subform is needed however it doesn't seem to work for me so I must be doing it wrong. How would I do this?

View 1 Replies View Related

Forms :: Return Value Based On Another Cell

Jul 9, 2014

I have a database (small one which i designed)

I have created all the tables.

I then have a "form" called July-14 (i need to figure out how i can automatically replicate this form for new months)

Anyway, one of the cells pulls out a product name (using the lookup wizard), i then have a cost cell which i would like to populate automatically based on the product name.

The table July-14 links to a product table which has ONLY those 2 attributes in there, the name and cost.

How do i get it to pull the cost automatically.

View 5 Replies View Related

Return Result Based On Percentage

Aug 8, 2012

I have a table that has 3 columns: Unique number, Date, and Results

I want the user to enter the unique number and date into the form. Then the "results" column/field will autopopulate a 0 or 1. I want it to populate a 0 85% of the time and a 1 15% of the time. This should be cumulative (meaning not every entry has a 15% chance of being 1). Is this possible?

View 1 Replies View Related

Return Value From A Table Based On A Text Field

Aug 27, 2006

I have created a text field on a form that uses the DateSerial function to return the value of last month e.g. Jul-06.

I have a table that contains months (e.g. Jul-06, Jun-06 etc) and a corresponding numeric value (e.g. 1,2,3).

I have another text box on the same form that I want to display the numeric value in based on the value that has been returned by the DateSerialfunction. What properties/control source should I set for this field? Or do I need to write some VBA?

Any help would be appreciated.

View 2 Replies View Related

Using A Checkbox To Return Text Based On Another Textbox

Apr 26, 2005

Dear All:

I have a form with three items:a checkbox called "Check231", a textbox called "text921" and another textbox called "text762".

What I wish to do is: Enter text in textbox921, which stays the same as I scroll through each record. Then If checkbox check231 is checked, it displays text from textbox921 to textbox762. Textbox762 is bounded to the form.

Any ideas on how to get started?

Many thanks,

Dion

View 1 Replies View Related

Modules & VBA :: Return Integer Based On Time?

Oct 30, 2013

I have a query with a Start Time where the need to return a set integer in another field in my query. I am attempting to get this to work in my StripSecondsQry.

I am not getting any error messages and I am not getting any output, When I view this in the Locals window I can see that it should be returning 7, but instead I get nothing unless I change it to

Code:
Function SortStart(StartTime As String) As Integer

then I get zero.

I had this working within the query, but I had to add one more time and then received a message that the expression was too complex.

Code:
Sort_Start: IIf([StartTime]="7:00 AM",1,IIf([StartTime]="8:00 AM",2,IIf([StartTime]="8:45 AM",3,IIf([StartTime]="9:00 AM",4,IIf([StartTime]="9:15 AM",5,IIf([StartTime]="10:00 AM",6,IIf([StartTime]="10:15 AM",7,IIf([StartTime]="10:30 AM",8,IIf([StartTime]="12:00 PM",9,IIf([StartTime]="1:30 PM",10,IIf([StartTime]="1:45 PM",11,IIf([StartTime]="2:00 PM",12,IIf([StartTime]="3:00 PM",13,IIf([StartTime]="4:00 PM",14))))))))))))))

View 3 Replies View Related

Queries :: How To Return Value Based On Row And Column Location

Aug 9, 2013

I inherited a spreadsheet that uses an Index (Match formulate to return a value. I want to use Access to manage the data going forward. I am just starting to build my tables in Access so I have some flexibility and want to do it right. Here is a sample of the data:

KeyEnroll JanFebMarAprMay
abc1/2013103521
def3/201300789
ghi5/201300008

So if Enroll date starts in Jan I want the 10 amt returned from the Jan column. If the Enroll date starts in March, for that client I want the March amy returned, etc.

results: for client "DEF" the amt returned should be "7" because their enrollment date is 3/2013.

View 4 Replies View Related

Return Multiple Results Based On A Field

Aug 27, 2015

Event#
EID
Arrived Time
Code
Cancelled Time

[code]...

I need to find all EIDs where the Code is 611 where an Event# starting with F was Cancelled along with the time of the cancellation. For these results I also need the Arrived Time for the Event# starting with E for that EID.For instance, a result I'm looking for would be:

EID
Event# (F)
Cancelled Time
Event# (E)
Arrived Time

[code]...

View 1 Replies View Related

If Statement That Will Return Data Based On Time Of Day?

Sep 23, 2013

I am trying to write an expression that will result in a date in the format (mm/dd/yyy). I want to display the curent day if it is before 11:00 am based on the system time, and the next day if it is after 11:00 am. Below is the expression that I currently am working with... but it is not working.

IIf(Time()>Hour(11),Date(),DateAdd("d",1,Date()))

View 5 Replies View Related

Please Help Asap .. Query Based On A Date

Mar 30, 2006

:confused: i am trying to develop a system which requires a date order to be used .. i want to use a filter query to filter out certain information from my tables into a form .. i know how to accomplish this but i am having a small problem getting there
i wish to set sunday to an order of one (1) and monday to two (2) and so on so that when i create my query i will be able to select the thursday for example ( by setting the criteria to a "5" )
i have a table consisting of the dates but i am unsure how to create a field that displays the order .. automatically calculating whether the date is a sunday or a monday and assigning the correct number as stated above, i have tried something (not sure what) which assigned a 1 to monday through 7 to sunday but this is not the order i wish to use and it failed to work with my query anyway
would this create this using my computers clock or something and if so what do i need to do to get this small part of my system up and running therefore enabling me to create my filter query
please help
thankyou :)

View 3 Replies View Related

Date Query Based On Month

Apr 3, 2007

I am very new to access so thank you in advance for your help and patience.

I have creadted a database for tracking students.

I would like to give them progress reports every three month based on thier start date (I have a 'short date' field for the start date).

If I run the query in January I would like results for all student who started in Jan, April, July & Aug.

Thank you again!

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved