Queries :: Append Query - Using Date Range From Separate Table?

May 1, 2013

I have an database that uses a couple of different date ranges, so I created a table that shows the different date ranges that may be required (xReport Dates) so I didn't have to keep manually editing queries or entering dates every time.

I have one query that appends data from one table into another based on a date range that you need to manually enter when prompted; I can't seem to get it to refer to my xReport Dates table for the range.

Its currently set up as below:

INSERT INTO 001_M_Gross_Telesales ( UpdateDate, OMSNumber, MediaRoute, ExecName, SaleType, Name,
[Reporting Campaign], [Reporting Team], [Sales Leader], [Reprting Name], [Media Route2] )
SELECT Max(L_ExecTracker.UpdateDate) AS MaxOfUpdateDate, L_ExecTracker.OMSNumber,
L_ExecTracker.Campaign, L_ExecTracker.ExecName, L_ExecTracker.SaleType, Z_Ref_Agent_Table1.Field23,

[Code] .....

View Replies


ADVERTISEMENT

Queries :: Getting Date / Time Range - Date And Time Are Separate Fields

Mar 13, 2014

I have a database with date and time each stored in a separate field. Now I want to query the database based on a start date/time and an end date/time. I started with the code below but it only returns events within the same time range on each day when what I really need is every event from a specified date and time through a specified date and time.

SELECT myTable.ID AS myTable_ID, myDate, myTime, FirstName, LastName
FROM Staff INNER JOIN myTable ON
Staff.ID = myTable.StaffID
WHERE myTable.myDate >= #3/2/2014#
AND myTable.myDate <= #3/3/2014#
AND myTable.myTime >= #8:00PM#
AND myTable.myTime <= #11:00PM#
ORDER BY myDate desc

In the above example what I want is every event from 3/2/2014 8:00PM until 3/3/2014 11:00PM. But what I get instead is every event between 8:00PM and 11:00PM on 3/2/2014 and every event between 8:00PM and 11:00PM on 3/3/2014.

View 4 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

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

Append A Date Range

Nov 27, 2006

Hi Guys

Can someone please help me with this? I have an Events form which has some date fields setupdate and enddate. There is a linked events calendar subform attached. I have attached the database for you to see.

If you open the events form and go to the events date tab, I want to be able to type in the dates in the setup and end date fields, and then run a query which populates the events calendar subform. I created a date table (dates) with a list of dates and tried to create an append query (Query3) with those fields as criteria which didn't work as it wasn't recognising the parameters (but i'm guessing that is because it wasn't attached to the Events Form). However after entering the dates, I was able to append them to the events calendar only after including the EventsID field to the dates table and the query. This however means that the records aren't linked to the Events table as the EventsID field is blank (the EventsID is what links the E.Calendar subform to the Events Form). Therefore though the records were reflected in the events calendar form, it wasn't showing up on the events form.

I dont know if this makes much sense but what I basically want to do is a series of functions. Create a query which extracts a set of dates based on criteria entered into the main form, and appends them to a datasheet subform which is linked to the main Events form via the EventsID, then copies the Event ID for all the recordsets that have been added.

Is this possible? Thanks for your help in advance.

View 2 Replies View Related

Queries :: Find Latest Date In A Table Where Dates Are In 2 Separate Columns And Multiple Rows

May 19, 2015

I am trying to find the latest date in a table where the dates are in 2 separate columns and multiple rows. (there are business reasons why there are 2 dates per row they represent different but comparable activities)

I have a table "Assessment tracker" with the following structure

Name Type
Candidate short text
Unit short text
EV1 Date Date
EV2 Date Date

My Data:

Candidate Unit EV1Date EV2 Date
TH1 10 07/05/2015 25/05/15
TH1 10 07/05/2015 07/06/15

I have a query "Candidate AC Dates" that compares the 2 dates EV1 and EV2 and outputs a 3rd column with the latest date.

Query:
PARAMETERS [Candidate Name] Value;
SELECT [Assessment Tracker].Candidate, [Assessment Tracker].Unit, [Assessment Tracker].[EV1 Date], [Assessment Tracker].[EV2 Date], Max(MaxDate([Assessment Tracker]![EV1 Date],[Assessment Tracker]![EV2 Date])) AS Achdate
FROM UnitData INNER JOIN [Assessment Tracker] ON UnitData.Unit = [Assessment Tracker].Unit

[Code]....

Output:

CandidateUnitEV1 DateEV2 DateAchdate
TH11007/05/2015 25/05/201525/05/2015
TH11007/05/2015 07/06/201507/06/2015

It does this by using a function shamelessly copied from the web somewhere...

Function Maxdate(ParamArray FieldArray() As Variant)
' Declare the two local variables.
Dim I As Integer
Dim currentVal As Date' Set the variable currentVal equal to the array of values.
currentVal = FieldArray(0)
' Cycle through each value from the row to find the largest.

[Code]....

This is working well (I think)

I then want to find the latest date for the 2 records i.e. the Max value for the Achdate.

Query:
SELECT [Candidate AC Dates].Candidate AS Expr1, [Candidate AC Dates].Unit AS Expr2, Max([Candidate AC Dates].Achdate) AS MaxOfAchdate
FROM [Candidate AC Dates]
GROUP BY [Candidate AC Dates].Candidate, [Candidate AC Dates].Unit
ORDER BY [Candidate AC Dates].Candidate, [Candidate AC Dates].Unit, Max([Candidate AC Dates].Achdate) DESC;

But this is returning

Candidate Unit MaxOfAchdate
TH1 1025/05/2015

I expect it to return

Candidate UnitMaxOfAchdate
TH1 10 07/06/2015

It looks to me like MAX is considering only the day value rather than the whole date. I suspect this is because it is considering the results of the function in the first query as a short text rather than a date field. (I've tried to force this through declaring the variables as dates but don't know where else to force this. (I am UK based hence the DD/MM/YYYY format)

View 14 Replies View Related

Queries :: Not In Date Range Query

Jan 10, 2014

I'm trying to produce a query that shows all records of patients that have a 'non-active' status (stored in the 'Patient Details' table) and haven't had any deliveries after 31/10/2011 (date stored in the 'Deliveries' table). I've tried a few different ways including using NOT IN (which access didn't like!) but I'm still no closer to getting the correct records.

View 2 Replies View Related

Queries :: And / Or Date Range Query

Sep 8, 2014

I am trying to create a simple database to keep track of employee Car Insurances and MOT information.I am trying to create a query that will show me the following:

When the field "motexpiry" is Empty OR has a date within 30 days from todays date (including if today's date is in the field) OR the date is in the past.It also needs to show records with the same criteria for the field "insuranceexpiry".

And needs to show records where the field "cowensform" is blank.These are all OR queries, so that as long as ONE of all of those criteria is met, the record shows up.Once that query works, I need a very similar query but only showing records where one or more of those criteria is met, but only if the record also has "Oldham" in the "area" field.

I can then copy that query and edit the "Oldham" bit to have a query for each of our area offices.I tried putting "Oldham" in the criteria line of the area field in the query design, but it seemed to have no affect.

View 14 Replies View Related

Queries :: Date Range Parameter Query

Jan 8, 2015

I have a query that is hard coded with a date range.

SELECT tblCase.CaseId, tblCase.ReqReceived, tblCase.Letter_AMPI,
FROM tblCase
WHERE (((tblCase.Letter_AMPI) Between #4/1/2014# And #3/31/2015#)) OR (((tblCase.ReqReceived) Between #4/1/2014# And #3/31/2015#))
ORDER BY tblCase.CaseId;

I would like to create a parameter query that allows me to only enter the year and the query would append the rest of the date range. So for example, if I prompt the user to enter the date and they enter 2014, the query would know that it means Between #4/1/2014# And #3/31/2015# or if I enter 2015, it means Between #4/1/2015# And #3/31/2016#.As well the date would need to go into both fields ReqReceived and Letter_AMPI.

View 3 Replies View Related

Queries :: Query For A Specific Date Range / Calculation

Jan 22, 2014

I am trying to calculate the total hobbs time (Ending Hobbs - Starting Hobbs = Total Hobbs) based on a user inputed date range. The query that I created (see attachment) doesn't seem to give me what I'm wanting.

View 14 Replies View Related

Queries :: Date Range Query And Null Records

Mar 5, 2014

I have two questions, both the same query.

I need a date prompt and null records in the same line of criteria so I get all those within a certain date range under the field "CO_resp_rcvd" and those that didn't respond yet but need to -- is that possible to do both and if so how would you show me how?

This is what I have currently in my query

CO_resp_rcvd (date field)

Criteria: Between [Start Date] And [End Date]

(I need null values as well because there will be some if the CO has not responded yet but needs to)

Formula:

This formula gives me the number of bus days from the Review Date - CO_Resp_Rcvd Date and that works but if the CO-Resp-Rcvd date is null, I need it to calculate Review Date - Today's date to show the number of days outstanding for those that have not responded yet in the same formula?

Not sure how to combine it to work - the wrapper is a bus day function

This is what I have so far in the query

CO-Bus Days to Respond: Wrapper([Review Date],[CO_resp_recd]) but if CO_resp_recd is null then ([Review Date],Date())

View 6 Replies View Related

Queries :: Filter Query To Calculate Sum Of Fields In Date Range

Nov 18, 2014

I have a table, tblDailyCalls, that contains agent_name, date, calls_ answered, and talk_time. Ideally on a form, the user will select an agent, enter the date range in txtStartDate and txtEndDate and a report opens to show what the total amount of calls and talk time is for that date range.

All I've managed so far is doing a simple expression on the report itself to sum the fields I want. But my method returns every date in the range. I would like to only display the total.

I've been trying with Totals in the query and crosstab queries but am not familiar with them.

View 4 Replies View Related

Queries :: MS Access Cross Tab Query - Date Range Filtering

Aug 14, 2013

I just wanted to know how can i set a parameter on the following cross tab query to filter dates. Date field is [pdate By Day].

TRANSFORM Sum([PettyMaster Query2].Amount) AS SumOfAmount
SELECT [PettyMaster Query2].[Petty Cat].Field2, [PettyMaster Query2].[pdate By Day], [PettyMaster Query2].ProjLoc, [PettyMaster Query2].descriptionofpay, [PettyMaster Query2].projno
FROM PettyMaster, [PettyMaster Query2]
GROUP BY [PettyMaster Query2].[Petty Cat].Field2, [PettyMaster Query2].[pdate By Day], [PettyMaster Query2].ProjLoc, [PettyMaster Query2].descriptionofpay, [PettyMaster Query2].projno
PIVOT [PettyMaster Query2].PettyCOA.Field2;

View 11 Replies View Related

Queries :: Create A Query Of All Employees Doesn't Have Any Transaction For A Certain Range Of Date

Mar 30, 2013

i'm trying to create a query of all employees doesn't have any transaction for a certain range of date and will also shows the last transaction date they have.i have two databases one is the transaction file and the other is the user file.

View 7 Replies View Related

Queries :: Getting A Query On Multiple Checkbox Fields To Work With A Date Range?

Nov 7, 2014

I have developed a database which has required many checkbox fields to enable analysis. It requires to have the facility to input random/variable date ranges for statistical purposes.

I have built a query which obtains the counts of multiple fields using the following parameters in Query Builder in Access 2010. Although this comes up with the correct results for these multiple fields when I try introduce date range the results come up blank for all results.

An example of the parameters used for one of the checkbox fields in Query Builder is as follows:

Field: SumAnger: Sum([Anger]*-1)
Table: Default as only one table
Total: Expression
Show: Checked

This works fine.

My latest parameters for the date range are this:

Field: [cDate]
Table: Default as only one table
Total: WHERE Corrected! Whoops Copy & Paste Typo. Too early AM!
Show: Checked or Unchecked makes no difference
Criteria: Between [From Date:] And [To Date:]

This gives a statement in SQL view of:

SELECT Sum([Anger]*-1) AS SumAnger, Sum([Anxiety]*-1) AS SumAnxiety, Sum([Depression]*-1) AS SumDepression, Sum([Listening]*-1) AS SumListenig, Sum([Psychosis]*-1) AS SumPsychosis, Sum([Stress]*-1) AS SumStress, Sum([Other]*-1) AS SumOther, tblCommsLog.[cDate]
FROM tblCommsLog
WHERE (((tblCommsLog.[cDate]) Between [From Date:] And [To Date:]));

what I need to get this to work in Query Builder or failing that recommend some VBA script/code with embedded SQL to achieve the required report.

View 1 Replies View Related

Queries :: Appointment Database - Query Most Recent Entry For Each Record In Separate Table

Jun 20, 2013

I have a database that is used to allocate appointments to our staff. It has 2 tables, one that lists the clients we need to call in that day, and another that stores details of each contact attempt. I'd like to design a query that find all clients who we have not dealt with so we can easily get their details in a list. I know what the criteria for the query would be, but I'm stuck for how to actually execute it. Here are the details.

Table tClients stores the current clients - primary key is named "clientRef"
Table tContactEvents stores each contact attempt and the date/time is stored in a field named "dateTime".

When an entry has been dealt with successfully a yes/no field named "completed" will be set to "Yes".

There may be many attempts to contact a specific client on a given day, unsuccessful attempts will not have the completed flag set.

Once the completed flag is set that client will be ignored so no further entries will appear.

So I need a query that searches tContactEvents for the most recent match to each number in tClients.clientRef and checks if the completed flag is set. If the completed flag is false, or if the number has no match (i.e. no contact attempts made yet) then the clientRef should be displayed. I also need this to be restricted to the current date, as the same client could have rebooked their appointment to a different day.

View 10 Replies View Related

Queries :: Take A Date From Textbox On A Form Into Append Query

Nov 26, 2013

how do you take a date from a textbox on a form into an Append query and increase the date entered into the textbox by 1 day.This is what I have so far but not working??

MealDate: [Forms]![FrmSwitchBoard]![txtweekend]=DateAdd("d",1,Date())

View 4 Replies View Related

Queries :: Show Data - Query Based On User Selected Time And Date Range

May 17, 2013

I have a form that request information from the user (StartDate, StartTime, EndDate and EndTime) the problem is that it's not working. The only way I can get any data to show is when I remove the StartTime and EndTime. Only then will it pull the items from the StartDate and EndDate.

Here is what I have as my criteria: Between [Forms]![OpPROD_ALL]![StartTime] And [Forms]![ OpPROD_ALL]![EndTime] And Between [Forms]![ OpPROD_ALL]![StartDate] And [Forms]![ OpPROD_ALL]![EndDate]

The users will be able to request a report based on a start and end date along with a start time and end time.

Side note: this is to pull date for 3rd shift (Example) 4/14/2013 10:00PM - 4/15/2013 10PM

View 1 Replies View Related

Queries :: Append Query For Temp Table

Mar 24, 2015

I am trying to create a table from a form. The form has several fields but I need to take the value from 4 separate combo boxes ([cr] +[br] +[tr] and add them, then add the value from one more combo box [inc] to be my beginning value in a table.

I then need to add the last value [inc] to the total and that become the next line in the table. I would the like to add this value [inc] an infinite number of times until it reaches a max number.

The scenario would be something like this
cr=3 br=2 tr=3 inc=1.5

So the first total would be 9.5. Then every row after that would be plus 1.5
11
12.5
14
15.5
17
and so on.

This would be a temp table that I would run a query on to let an operator know lengths they can choose from in a combo box. I don't know if this is even possible.

View 3 Replies View Related

Queries :: Crosstab Query Which Can Append To Table

Jan 8, 2015

I have a crosstab query which i would like to append to my table..can't change it to a append query...it changes the structure.

View 1 Replies View Related

Queries :: Append Query Not Appending Entire Table

Feb 27, 2015

I have a local table that I am trying to append to a linked table. The fields are exactly the same. When I try to append the entire local table to the linked table I get an error code.

ODBC- insert on a link table failed.
[ctreeSQL]-17002 CT- Key value already exists in index (linked table field) (#-17002)

If I specify the criteria in the field to refer to a specific value in the local table, it updates it just fine. I want an append query because I don't want to manually update 500+ records!! I don't believe an update query would work because the values are not in the current linked table... so nothing to update!

View 8 Replies View Related

Queries :: Append Query For Multiselect Combo Box (has 2 Table)

Jul 11, 2013

"I have 1 "main" access file and "Portable".

In the form of main I creat buttom to open and apped the table of other access file-portable.accdb- to the main table!"

I had a problem before about attachment field appending anj JHB solved that problem in this link.

"I have 1 "main" access file and "Portable".

In the form of main I creat buttom to open and apped the table of other access file-portable.accdb- to the main table!"

See that problem and download attachment of that topic.

But I want to append a table with multi select combo box. That combo box field has query from table "list" and i want to append this 2 table (asli & list) to a main database!!!

Attachment instruction:
1-solved pervious problem(OK)
2-problem with combobox query(has ERRROR)

View 14 Replies View Related

Queries :: Append Query Needs To Add Data From A Field To The Table

Mar 13, 2014

I want to set a table field's default value to whatever is displayed in a certain field on a certain form at the time.In other words, say I have a database with a table called TABLE1, and two fields called NAME and SCHEDULENUMBER. I have a form called CreateSchedule with a SCHEDULE NUMBERCONTROL form and a NAME form, and I can enter names onto it, and it records to the proper SCHEDULENUMBER. So if I pull up SCHEDULENUMBER 4, and add three names, when I go back into TABLE1, I can see those three new names, and each one has the SCHEDULENUMBER set to 4.

What I'm trying to do is write an APPEND QUERY to copy a list of names from a different table, and paste them into TABLE1. The problem is that the other table doesn't have a SCHEDULENUMBER field. What I want to do is put a button on the CreateSchedule form that runs an APPEND QUERY, and sets the SCHEDULENUMBER to whatever value is displayed on CreateSchedule's SCHEDULENUMBERCONTROL field.

I tried setting a default value in TABLE1's field properties for that SCHEDULENUMBERCONTROL field, but I keep getting error messages. I just want TABLE1, whenever I add a new record (regardless of how I add the record: manually typing it or clicking the append query button) to look at the form CreateSchedule, and set it's own SCHEDULENUMBER field to whatever is displayed in CreateSchedule's SCHEDULENUMBERCONTROL form.

View 1 Replies View Related

Queries :: Run Append Query From Table A To Table B

Jul 30, 2014

how I could run an append query from table A to table B that only appends data that is not in table B.I want the primary keys of A to be exactly the same as B, because I will use B as a blank slate (another append query to append info to another table C with all the fields as 0 except for the primary key).

For example,

Table A - Supplier
Table B - Things that supplier does (blank)
Table C - Things that supplier does (information)

Lets say table A has 1,2,3,4 for supplier.Table B has 1, 2, 3, 4, as primary keys as well but all the other fields are zero.I insert PK "5" + data into table A through a data entry form, and then when I click on "save" in the data entry form, I want to macro an append/update qry (I don't know which one is supposed to be used in this instance) that will insert PK-5 into table B, so that I can append the blank slate info into table C.

View 1 Replies View Related

Full Outer Join Queries And Make Table / Append Query

Jan 20, 2014

I am fairly new to Acces 2010.I have two seperate tables hat I need to use to compare data. As you can see table A and table B have some of the same item numbers but they also have different item numbers that are not other table. Also some of the item numbers are duplicated in each table but that is okay because the cost of the item is different. Both tables contain item numbers for the products. I want all of Table A item numbers including the item numbers that are in table B. But I also want Table B item numbers except for the item numbers that are also in Table A. In the real raw data file some of the item number fields are blank but the other fields have values. How should I query these tables so that I achieve the correct results?

Table A
Item Num Costof Item Supplier Sales Tax Purchase Month
1234 $1.00 Walmart $2.00 Dec 2013
2222 $4.00 Walmart $1.00 Dec 2013
2222 $2.00 Walmart $1.00 Dec 2013
1276 $3.00 Sams club $1.50 Dec 2013
7898 $5.00 Texaco $5.00 Dec 2013
4567 $3.50 Food Lion $1.00 Dec 2013

[code]....

View 3 Replies View Related

Queries :: Press A Button And Run A Macro / Append Query To Add A Single Summary Record To Another Table

Aug 2, 2013

I have a query run that gives me a list of records that I view on a continuos form. What I want is to press a button and run a macro/Append Query to add a Single Summary record to another table.

For example my query spits out this data

Part # Quantity Serial Number
GO2 1 123
GO2 2 456
GO2 2 789

What I'm looking to get is

Part Number Total Quantity Serial Number 1 Serial Number 2 ..
GO2 5 123 456

I'm stuck on a couple of things.

1. Getting a new single row to append.
2. Getting Serial Numbers from several records to save on to a single record.

View 4 Replies View Related







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