MS Access "Joins", Possible To Join Via A Range Or Add Code?

Nov 2, 2007

hi im pretty new to this, using access2000 i believe


i have a large amount of data and have been able to join them successfully. using the "left" "Operator" "right"


one of the things id like to join are dates, but the dates i want to join are not exactly equal to each other so i cant just use a operator "=".


i need to be able to tell access to link the dates within say 30 days of each other.



Ideally something like “left” “>” “right” -30


currently im using excel to do this for me but if access can do it then it would be great.


in excel i use a macro which matches dates within 30 days, and just use a simple

If range("A1") < range("A2") + 30 and range("A1") > range("A2") - 30 then ...........




so is it possible to have access join things within a range?


would be grateful for any help ;)

View Replies


ADVERTISEMENT

Develop A Query In MS Access 2010 To Join Two Tables Using Three Joins One Of Which Is A Date Range

Apr 15, 2015

I am trying to develop a query in MS Access 2010 to join two tables using three joins one of which is a (between) date range. The tables are contained in Access.

ABCPART links to XYZPART. ABCSERIAL links to XYZSERIAL. ABCDATE links to (between) XYZDATE1 and ZYZDATE2.
[ABCTABLE]
ABCORDER
ABCPART

[code]...

View 4 Replies View Related

Query Using Joins To Disply All Records From Both Sides Of Join Type

Apr 14, 2008

I have a list of PC SN#s in tbl1;
I have a list of other PC SN#s in tbl2
I want to display ALL records of tbl1, AND ALL records of tbl2, matching up the SN#s (where there is a match) - but I want to display all records whether they match or not.

How can I accomplish this?

View 1 Replies View Related

Join Based On Date Range

Jan 24, 2006

ive got two tables that i need to merge.

I need the join to work so a date within table b links to a range in table a of 2 columns start and end- is it possible?

Ie
Table A
patient number
admitted date
discharged date
etc
etc

Table B
Patient number
operation date (will lie in admit dis date)

NB a patient number may exist in table A and not B, or table A twice at differnt times and B once.

thanks, ren

View 1 Replies View Related

Modules & VBA :: How To Do A Join Range Query

Dec 9, 2013

I am currently trying to do a range join query in access (not an expert at all with it) but I realized that it's not easy. It probably needs a VBA code but still not sure how to do it. I basically have a column with number of days e.g

Number of days
18
1
0
56
8
-19
369

Eventually I would like to do a range join query (similar to excel range vlookup) with the following table

NumberofDaysWeeks
0 Same Day
1 1 Week
7 1 Week +
14 2 Week +
21 3 Week +
30 1 Month +
60 2 Month +
90 3 Month +
120 4 Month +
150 5 Month +
180 6 Month +
210 7 Month +
240 8 Month +
270 9 Month +
300 10 Month +
330 11 Month +
360 12 Month +

After joining the two tables with an approximate range (as in excel) the final table should look like below

Number of days Weeks
18 2 Week +
1 1 Week
0 Same Day
56 1 Month +
8 1 Week +
-19
369 12 Month +

Note that value -19 is an error so it should not return anything however i still want to see the value in the final table.

View 4 Replies View Related

Queries :: Complex Join Based On Date Range

Jul 29, 2013

Context is I have a TABLE 1 that has a record for every package shipped with various details about it, include how it shipped, and the date. Table 2 is a key to go from the ship method to a better grouping we deem service level. Table 3 is a Fuel Surcharge (FSC) Table. It includes various FSC % that vary by different service levels and different date ranges. In the end I need to know the amount of pkgs shipped (by month and servicelevel) and the relevant FSC.I have several tables in my database but we should be able to focus on 3 to explain my situation and only the relevant fields:

TABLE 1 (Main Data):
ShipDate
ShipVia

Table 2:
ShipVia
ServiceLevel
FSCType

Table 3:
FSCType
StartDate
EndDate
FSCPercent

DESIRED RESULT:
Month
ServiceLevel
FSCPercent
PkgCount

Table 1 is Left join on Table 2 based on ShipVia
Table 2 is Left join on Table 3 based on FSCType
The issue is Table 3 is dependent on Table1.ShipDate being between the date ranges as well.

There are overlapping date ranges, however they are differentiated by the FSCType field.The only semi-feasible solution I currently have is to expand Table 3 to include every date, and not date ranges. This will create an issue due to size of date ranges etc.

View 8 Replies View Related

Charts - Controlling Data Range With Code

Jan 30, 2008

I have a nice chart that hasd done what I wanted it too.

Now I want to make the amount of X-AXIS data variable. Typically this would be 64 points. If you look at the datasheet, I can manually set the number of points by making sure the row selector is "raised".

Now that's say there is only 16 points of data to control. I can plot that those points but the chart is still 64 points wide with no data for points 17-64.

How can I, through code, prevent points 17-64 from plotting and thereby expand the graph horizontally larger and not display those null points?

I have tried a number of things including:
objDataSheet.Row(17).Delete
Graph_Data.Range("A1:A16:)
etc...

Nothing I have tried has worked. Is what I need to do possible?

Thanks much.

View 2 Replies View Related

Access Keeps Changing My Joins

Dec 4, 2007

Good day all

I have a simple query linking two tables using the primary keys from each. The problem is that every time I go into design mode of the form that uses the query to populate a list box I get a Data Type Mismatch error and when I look at the query, Access has changed the join from the Pk in one table to the field after the PK in the other field. I have attached an image to show the change. Note that the join should be from the first fields on each table. I am really stuck with this guys, it is gettin me down and preventing me from developing the database further and my boss is on my case. Can anyone please help me? I have checked all the table relationships and they are fine. Thank you.

Gareth:(

View 13 Replies View Related

SQL Expert Help Needed- Getting Complex Joins To Work In Access

Jun 28, 2006

I am trying to execute the SQL below (tested in other programs, works fine) but access is giving me the "join expression not supported" error. How can this query be used in MS Access? I have tried breaking some of the joins clauses into separate queries, but I can't get it to work and it is making things much more complicated. Also note that moving the join conditions to the where clause could impact performance (this is a very large DB) Could I execute this via code somehow? Thanks.

SELECT lp.loan_id, lp.days_delinquent, lp.current_balance, pc.product_name
FROM mtgwl.loan_payment lp
inner join mtgwl.deal_loan_relation dlr on
lp.loan_id=dlr.loan_id
and lp.time_out='9999-12-31-23.59.59.0'
and lp.as_of_date='2006-04-30'
and dlr.time_out='9999-12-31-23.59.59.0'
and dlr.type='DEAL'

inner join mtgwl.deal_loan_relation pdr
on dlr.deal_id=pdr.loan_id
and pdr.time_out='9999-12-31-23.59.59.0'
and pdr.type='PRODUCT'

inner join mtgwl.product_control pc
on pc.product_id=pdr.deal_id
and pc.time_out='9999-12-31-23.59.59.0'
and pc.product_name='GSAMP 2003 AHL'

View 2 Replies View Related

SQL Expert Help Needed- Getting Complex Joins To Work In Access

Jun 28, 2006

I am trying to execute the SQL below (tested in other programs, works fine) but access is giving me the "join expression not supported" error. How can this query be used in MS Access? I have tried breaking some of the joins clauses into separate queries, but I can't get it to work and it is making things much more complicated. Also note that moving the join conditions to the where clause could impact performance (this is a very large DB) Could I execute this via code somehow? Thanks.

SELECT lp.loan_id, lp.days_delinquent, lp.current_balance, pc.product_name
FROM mtgwl.loan_payment lp
inner join mtgwl.deal_loan_relation dlr on
lp.loan_id=dlr.loan_id
and lp.time_out='9999-12-31-23.59.59.0'
and lp.as_of_date='2006-04-30'
and dlr.time_out='9999-12-31-23.59.59.0'
and dlr.type='DEAL'

inner join mtgwl.deal_loan_relation pdr
on dlr.deal_id=pdr.loan_id
and pdr.time_out='9999-12-31-23.59.59.0'
and pdr.type='PRODUCT'

inner join mtgwl.product_control pc
on pc.product_id=pdr.deal_id
and pc.time_out='9999-12-31-23.59.59.0'
and pc.product_name='GSAMP 2003 AHL'

View 1 Replies View Related

Access Projects - Query Designer - Update Queries With Joins Cannot Display In GUI

May 26, 2005

Hi, Big Jim here:

I am really not sure where to ask this one.....

My boss and I are in a jam. We have been using Access to run a reporting process, but one of our tables will exceed the maximum fields allotted this month. Our thought, dump the table into SQL Server and use the GUI interface provided in Access Projects.

Unfortunately, the query designer seems to have a few drawbacks. The one that effects us the most is in using UPDATE queries where more than one table is used to determine records to be updated. In attempting it, we get the message: "The designer does not graphically support the Optional FROM clause SQL construct".

Now I know we can manually create Update Queries, but we often need 1,000+ in a short period of time. Manually punching in all the fields involved and other code just isn't timely.

Question: Is there some alternative, service pack or anything else that would allow us to graphically create these Update Queries using Access Projects or even SQL Server 7.0? I would hate to have to scrap all the work we did over something that seems so minor.

Thanks in advance!

Big Jim


Set Up:
Windows XP
Office XP
SQL Server 7.0

View 4 Replies View Related

'JOINS' Need Advice On Joins

Aug 14, 2007

Hi again,

I just restructured my DB and I was wondering if anyone can give me some advice on whether or not my joins/relations are correct. I left some joins/relations out because I wasn't sure what relation I should use.

Any Advice will be greatly appreciated

18418

View 2 Replies View Related

WHERE Clause On LEFT JOIN : Why Do I Get Join Expression Not Supported Message?

Nov 10, 2006

I've been toiling with the issue of WHERE clauses on the "Right" side of Left Joins. I'm aware that you need to use JOIN ON......AND.... rather than JOIN ON....WHERE.... if the WHERE relates to the Right Hand table.

I've even got an example in my DB where the above works, but now am struggling to use the same theory for other tables. Therefore, I went and created two Mickey Mouse tables to test the logic but am getting an error.

I have
Table 1 with one field called Field 1 - values A, B, C
Table 2 as follows

Field 1.....Field 2.......Field 3
A.............100
C.............200..........XXX

I hoped to have a query that finds all records on Table 1 and records on Table 2 where Field 1 matches on the two tables and Field3 = XXX

My SQL is
SELECT Table1.Field1, Table2.Field1, Table2.Field2, Table2.Field3
FROM Table1 INNER JOIN Table2 ON Table1.Field1 = Table2.Field1
AND Table2.Field3="XXX";

but I get Join Expression not supported

What am I doing wrong?

Thanks
Andrew

View 7 Replies View Related

Create A JOIN Of Different Tables Called Join A Variable And List

Nov 16, 2013

And then called this join as a symbol or variable, and then have it use to select the items from these joined tables, can this be done in Access? Here is an example of a code that I created, but it has an error message saying the FROM syntax is incorrect.

Code:
SELECT firstJOIN.trainID, firstJOIN.trainName, firstJOIN.stationID, firstJOIN.stationName, firstJOIN.distance_miles, firstJOIN.time_mins
FROM (trains INNER JOIN ((station INNER JOIN lineStation ON station.stationID = lineStation.stationID)
INNER JOIN bookingLeg ON bookingLeg.startID = station.stationID or bookingLeg.endID = station.stationID )
ON trains.trainID = bookingLeg.tid) as firstJOIN

Can Access do something similar to this, in the FROM statement I joined 4 tables, because each unique fields are in each table and I have to joined them to get those fields. I called this join firstJOIN and in the SELECT statement, I list those columns in the table by calling it firstJOIN.trainID. Can Access do something like this, but syntax it differently?

View 6 Replies View Related

Access Join Output

Apr 12, 2007

I have two access tables that I am joining. In the opty table I want all records that meet the WHERE clause and in the activity table I want any/all that meet the join clause. The opty table has a one to many relation to the activity table. The join works correctly, it is the display that I am having problems with. I want the output display as an opty then under that all the activities associated to the opty in ASC date order. My problem is I have a memo field in the opty table I want to display but if I put a GROUP BY clause in the sql then I only get part of the memo field (I know why this is happening). So, I tried to leave out the GROUP BY in the sql and use the OUTPUT GROUP BY in the display section. This works except if there are numerous activities associated to an opportunity then the opportunity (sometimes) will be displayed twice with different activities listed. Can some please help.

If I use the the ORDER BY, and put CDATE(acty_begin_dt), I get a NULL error. Which, I assume is because some of the opty's may not have an activity associated to it.

Below is the code I am using and it works fine except, the activities are not in the correct order. (I am using this query in a cold fusion application using access db)
Thanks


SELECT opty_row_id, opty_name, opty_created_by, opty_stage, opty_type, acty_type, acty_created_by, acty_status, acty_opty_row_id, acty_desc, acty_comments, opty_primary, opty_create_dt, opty_close_dt, opty_est_value, opty_desc, acty_row_id, acty_begin_dt, acty_end_dt
FROM opty LEFT JOIN activity ON (opty.opty_row_id = activity.acty_opty_row_id)
WHERE (Trim(opty_primary) = '#form.rpt_user_name#' AND (CDate(opty_create_dt) between #get_first# AND #get_last#)) OR (Trim(opty_primary) = '#form.rpt_user_name#' AND (CDate(opty_create_dt) < #past_date# AND (Trim(opty_stage = '01 - Prospecting') OR Trim(opty_stage = '04 - Opportunity') OR Trim(opty_stage = '03 - Qualification'))))
GROUP BY opty_row_id, acty_row_id, acty_begin_dt, opty_name, opty_created_by, opty_stage, opty_type, acty_type, acty_created_by, acty_status, acty_opty_row_id, opty_primary, opty_create_dt, opty_close_dt, opty_est_value, opty_desc, acty_end_dt, acty_desc, acty_comments
ORDER BY CDate(opty_create_dt) Desc

View 1 Replies View Related

Syntax For Nest JOIN In MS Access?

Feb 22, 2008

This query works:

SELECT p.AcntNumber, p.Name, d.FromDate
FROM Daysheet AS d
INNER JOIN Patient AS p ON d.AcntNumber=p.AcntNumber

But this does not:

SELECT p.AcntNumber, p.Name, d.FromDate, c.CPT
FROM Daysheet AS d
INNER JOIN Patient AS p ON d.AcntNumber=p.AcntNumber
INNER JOIN Charge AS c ON c.Id=d.ChargeNum

Nor this:

SELECT p.AcntNumber, p.Name, d.FromDate, c.CPT
FROM Daysheet AS d
(INNER JOIN Patient AS p
(INNER JOIN Charge AS c ON c.Id=d.ChargeNum)
ON d.AcntNumber=p.AcntNumber)

How do you word a nested join?

View 2 Replies View Related

Does Access Recognise Anti-join?

May 19, 2006

Hello,

I'm merging de-duping contact data from 2 tables with the same fields. One table is the master (lets call it X) and the other is new data (lets call it Y).

However, it's not a simple as adding the new recordset to the old recordset: there are many dupes - sometimes X data needs to be replaced with Y data, sometimes the X data is more comprehensive than the Y data so the Y data is discarded, but often Y and X records for matching email addresses needs to be merged.

I currently have a union query joining the two tables (X and Y), upon which a make table query is based. A de-duplication query has been based on the resulting table of all records (X + Y), and exact duplicate/fragment 'Y' records in the table have been removed.

I have in my mind a diagram of a right-outer-join query (where the left table is X + Y and the right table is the original table X) - and I want the data that would be excluded from this operation. I have come across un-join queries in discussions relating to Oracle, can I use this operator in Access or is it incompatible with the Jet engine?

Would I just be able to use "IS NOT" somewhere in the right-outer-join query instead?

Please help! Thank you!

View 4 Replies View Related

Access Slow To Sum Or Join On Null Values?

Oct 5, 2006

Is Access slower at summing null records than SQL server?
I have a query which takes less than 1second in SQL server but takes about 5-10 in Access but can't think why there is such a lag in processing speeds.

View 7 Replies View Related

MS Access Lookup And Compare A Range Of Number...is This Possible ?? Please Help !!!!

Jul 17, 2006

I was wondering can MS Access do a range compair look up. I have 2 tables. One is the Info table and the other is Rate table. The Info table has 3 columns like this:

[code]...

I want access to read the Info table and pick up the values in the FICO, LTV and Type and compair it. Like with the above example. In the Info table FICO = 622. So then I want it to carry the number 622 down into the Rate table and compare that the number 622 is in FromFICO and ToFICO column to find where does 622 falls in between. In this case there are nine rows in the Rate table that 622 is between 620 and 629. The next criteria is the LTV number in the Info table. It's 76. So back into the Rate table looking for the number 76. And 76 is happen to fall between 75.01 and 80.00 in the FromLTV column and ToLTV column. Next back to the Info table is the Type column which is 2. Now back to the Rate table to look up the Type column for Type = 2. So from FICO = 622 , LTV = 76 , Type = 2...So the rate I want to populate is 0.25...So is this possible to do in Access?

View 1 Replies View Related

Date Range Specification - MS Access 2003+ ASP

Jul 9, 2007

I have a database that gets updated twice per week. Using ASP, I am "publishing" this database to our company website to enable anyone within the company (here or aboad) to see the status of various tests. The problem I am having is: I am trying to get only "active" tests to show up (which I have working correctly) or tests that have been stopped or completed within the past 5 days. I have tried using: DateAdd("d",-5,Now()), DateAdd("d",-5,Date()), and neither have worked. Any suggestions on how to get this to work? I can't use a specific date to subtract from, because it may be a few days between the time I update and the time everyone has seen it.

View 9 Replies View Related

Join Syntax Errors Translating Oracle SQL To Access SQL

Mar 21, 2008

I've developed a working query to grab some information from my Oracle 9i database using SQL Developer. I have a tool in MS Access 2003 that I'm developing for other users so they can input some options through the GUI and query the same data that I do.

I'm trying to translate the query I developed in Oracle and have it work in Access. I have my ODBC connection set up so that Access can get to the same tables.

Here is my Oracle Query:

[QUERY]...

The error I'm receiving is: Run-time error '3296'

Join expression not support.

I believe the error has something to do with the "LEFT JOIN CPCF ... " but I can't seem to figure out how to fix it. The query will run in Access if I change that to an "INNER JOIN CPCF ...." but the result set is not what I need it to be. Any thoughts on how to fix this?

View 1 Replies View Related

Queries :: Full Outer Join In Access 2010?

Jan 21, 2015

I would like to create a full outer join in Access2010 between two tables with many to many relationship.

So I have tblServer and tblApplication and there is also the ServerID-ApplicationID table that connects these tables.

I found online many examples but all of them where for two tables with one-to-many relationship.

View 6 Replies View Related

Queries :: Access 2010 / Join Expression Not Supported

Jul 1, 2015

I am trying to execute the query below with multiple left joins because of the data I am trying to get back. The weird thing is sometimes it work and then sometimes it gives me a join expression error. It seems that access strangely removes brackets around the ON clauses. However even when I put those brackets back in this query it isn't working. why this query isn't running or why the brackets disappear in Access 2010.

SELECT Patients.[First Name] & " " & Patients.[Surname] AS Fullname
, [Clinic Patient].[MYMOP ID]
, NZ(MYMOPs.[MYMOP Date], [Clinic Patient].[First Appointment]) AS [MYMOP1 Date]
, MYMOPs.Completed AS [MYMOP1 Completed]

[code]....

View 14 Replies View Related

Queries :: Access 2003 - Join Via Calculated Field

Apr 28, 2013

I'm stuck in Access 2003 - the group I am working with is unwilling to upgrade due to costs, and I've inherited this database (or I should say, a glorified spreadsheet), so unfortunately I am stuck with the tools that I have to use.

So I have Table A:MemberID (autonumber, Primary Key)

NameLast (Text)
NameFirst (Text)
TLBeginner (Yes/No) - Training level
TLIntermediate (Yes/No) - Training level
TLContinuing (Yes/No) - Training level
TLAdvanced (Yes/No) - Training level

I have created Query1 with the above table and added in a calculated field which essentially takes the training levels and converts it to a decimal number (basing it off a binary number of the 4-bits/Yes-no fields) with the calculated field below:

TrLevelTxtID: IIf([TLFundamental]=True,1,0)*1 + IIf([TLIntermediate]=True,1,0)*2 + IIf([TLContinuing]=True,1,0)*4 + IIf([TLAdvanced]=True,1,0)*8

So the calculated field works great - Depending what training levels are selected or not selected, I get a range between 0 through 15.

Table B: I want a list of "friendly name" for the different training levels.

TLID (Number, No duplicates)
TLFriendlyText (Text)

So what I want to be able to do, is to have Query1, that will pull the training level text (TLFriendlyText) within the query based on the calculated field (TrLevelTxtID). The catch is, I can't seem to create a join between the two tables with the calculated field.

Ideally, I want the final query to pull, [NameFirst], [NameLast] from TableA and [TrLevelTxtID] (from TableB) based on the queries calculated field [TrLevelTxtID].

How best to achieve this with the Access 2003 limitations. Also, this query will only be used for reporting/mail merging so there are no update requirements or concerns.

View 4 Replies View Related

Queries :: Access 2010 - Inline Query Using Inner Join And Group By?

Nov 14, 2013

I am currently using INNER JOIN and GROUP BY to narrow down the RowSource of a combo box based on the value selected in the active combo box where the code is located "onClick".

The value being selected is a StoreID, This ID is matched against the AssetRegister to find all group names, The GroupID and GroupName are then retrieved from the AssetGroup table, then finally the list is grouped on the Group ID and Group Name.

I have tested this query in SQL Server Management Studio and it works without any issues, however when I use it as an inline query to adjust the row source of the combo box it returns no values.

Here is the SQL query:

Code:
SELECT AssetGroup.ID, AssetGroup.GroupName
FROM AssetGroup
INNER JOIN
(SELECT AssetRegister.AssetGroup, AssetRegister.Store
FROM AssetRegister
WHERE AssetRegister.Store=7) AS ar ON (ar.AssetGroup = AssetGroup.ID)
INNER JOIN Store ON Store.ID = ar.Store
GROUP BY AssetGroup.ID, AssetGroup.GroupName ORDER BY AssetGroup.GroupName

And here is the inline query applied to the RowSource:

Code:
AssetGroup.RowSource = "SELECT AssetGroup.ID, AssetGroup.GroupName FROM AssetGroup INNER JOIN " _
& "(SELECT AssetRegister.AssetGroup, AssetRegister.Store FROM AssetRegister WHERE AssetRegister.Store=" & StoreID & ") AS ar ON (ar.AssetGroup = AssetGroup.ID) " _
& "INNER JOIN Store ON Store.ID = ar.Store GROUP BY AssetGroup.ID, AssetGroup.GroupName ORDER BY AssetGroup.GroupName"
AssetGroup.Requery

View 4 Replies View Related

Modules & VBA :: Naming Range To Export Data To Access Table?

Dec 15, 2014

I am trying to write code in an excel worksheet to try to export excel data to a table in access.

The range in which the data is situated in excel varies. So the range address varies with the data. After a lot of searching I wrote the following code which works for a range which is fixed. The code is the following:

Dim acc As New Access.Application
Range(Range("b22"), Range("b22").End(xlDown)).Select
ActiveWorkbook.Names.Add Name:="ghazla", RefersTo:=Selection
acc.OpenCurrentDatabase "D:PayRollFactoryJasminePayroll.accdb"
acc.DoCmd.TransferSpreadsheet _

[Code] .....

As one can see from the first two lines of code I am trying to first delineate the range and then to name it. The intent is to name the range "ghazla" and so to cater for the fact that the extent of data varies.

The code works with the fixed range ="Sheet2$B140". However what I need to do is to adjust the code so that I can insert "ghazla" as the range name so that this can vary.

View 5 Replies View Related







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