George-Bowyer
Registered User.
- Local time
- Today, 05:35
- Joined
- Dec 21, 2012
- Messages
- 178
Oh, lordy! I have been building my own access database for various work applications since 1997, but whilst i have taught myself to understand quite a lot of VBA in that time, queries have always worked or not worked purely because the magic query fairy says so...
It is entirely my own fault, but SQL is still mostly an unknown country as far as I am concerned.
I have list of organisations, in tblOrganisations, OrganisationID being the primary key.
Each organisation can be in one or more Association. This is recorded in tblOrgAssoc (OrgAssocID (PK); fldOrgID; fldAssocID). Each org can only be linked with any assoc once.
I have another table of records connected with various Organisations (tblAnnualReturns), with fldOrgID and various other fields.
I am trying to create a datasheet to update records in tblAnnualReturns, which works fine if I look at all the records.
However, I want to be able to limit it to only the records from Organisations within one Association.
Here is the sql so far:
SELECT tblAnnualReturn.fldOrgID, tblAnnualReturn.fldDateRecieved, tblOrganisations.FldOrgName
FROM (tblOrganisations INNER JOIN tblAnnualReturn ON tblOrganisations.OrganisationID = tblAnnualReturn.fldOrgID) INNER JOIN tblOrgAssoc ON tblAnnualReturn.fldOrgID = tblOrgAssoc.fldOrgID
WHERE (((tblAnnualReturn.fldYear)=DatePart("yyyy",Date())) AND ((tblOrgAssoc.fldAssocID)=307))
ORDER BY tblOrganisations.FldOrgName;
It shows the info I want fine, but I can't edit fldDateRecieved, which is what I am trying to achieve.
I am fully aware that I ought to know a lot more about sql and query structure then I do - but alas I don't, so if anyone could give me a steer, I'd be grateful...
It is entirely my own fault, but SQL is still mostly an unknown country as far as I am concerned.
I have list of organisations, in tblOrganisations, OrganisationID being the primary key.
Each organisation can be in one or more Association. This is recorded in tblOrgAssoc (OrgAssocID (PK); fldOrgID; fldAssocID). Each org can only be linked with any assoc once.
I have another table of records connected with various Organisations (tblAnnualReturns), with fldOrgID and various other fields.
I am trying to create a datasheet to update records in tblAnnualReturns, which works fine if I look at all the records.
However, I want to be able to limit it to only the records from Organisations within one Association.
Here is the sql so far:
SELECT tblAnnualReturn.fldOrgID, tblAnnualReturn.fldDateRecieved, tblOrganisations.FldOrgName
FROM (tblOrganisations INNER JOIN tblAnnualReturn ON tblOrganisations.OrganisationID = tblAnnualReturn.fldOrgID) INNER JOIN tblOrgAssoc ON tblAnnualReturn.fldOrgID = tblOrgAssoc.fldOrgID
WHERE (((tblAnnualReturn.fldYear)=DatePart("yyyy",Date())) AND ((tblOrgAssoc.fldAssocID)=307))
ORDER BY tblOrganisations.FldOrgName;
It shows the info I want fine, but I can't edit fldDateRecieved, which is what I am trying to achieve.
I am fully aware that I ought to know a lot more about sql and query structure then I do - but alas I don't, so if anyone could give me a steer, I'd be grateful...