We help IT Professionals succeed at work.

Access Doable?

458 Views
Last Modified: 2014-08-11
Hello All,

Here is the original question where I wanted to added missing rows to the table:
https://www.experts-exchange.com/Database/MS-SQL-Server/Q_28476836.html

But the problem is now this has to happen in access as all users are in that platform and need this to do the same thing but in access (not SQL server)
So after spending some time, I couldn’t figure it out….some TSQL stuff will not work in the access query structure…aint it?
Can anyone guide me. I have attached the access sample DB for reference as well


Within the access file – table “sheet1” is where I want to add the missed rows. Table “sheet2” has all possible week strings


Thank you
SampleDBPlease.zip
Comment
Watch Question

Author

Commented:
All Experts are welcomed

Author

Commented:
so how can i write a query within access that adds the missed possible rows to sheet1 table...

Author

Commented:
something like this? maybe

(SELECT *
from
(select
distinct account,item from sheet1 ) a ,(select [End To End Week] from sheet2) b )

still ...not sure

Author

Commented:
select * from
(SELECT *
from
(select
distinct account,item from sheet1 ) a ,(select [TETEW] from sheet2) b ) E
where E.week not in ("")

not sure again

Author

Commented:
The access sql should first find the Cartesian products (all possible combination) of the account, item and week.
 Then the query should only show those combinations of account,item and week that were not originally present in table "sheet1"
PortletPaulEE Topic Advisor
CERTIFIED EXPERT
Most Valuable Expert 2014
Awarded 2013

Commented:
In Access that query needs change for coalesce and 'cross join' and convert(null,int)

for the 'cross join' just use a comma between the table names instead

for coalesce() use Nz()

and CInt
select
        dod.Account
      , dod.Item
      , dod.itemDescription
      , dod.[item Grp]
      , wks.week
      , NZ(od.AmountL1,0)     AmountL1
      , NZ(od.AmountK2,0)     AmountK2
      , NZ(od.[dim Length],0) [dim Length]
      , NZ(od.WeekTY,0)       WeekTY
from (
      select distinct
              Account
            , Item
            , itemDescription
            , [item Grp]
            , CInt(null) AmountL1
            , CInt(null) AmountK2
            , CInt(null) [dim Length]
            , CInt(null) WeekTY
      from originalData
     ) dod, "total End to End Weeks" as wks
left join originalData od
      on  dod.Account = od.Account
      and dod.Item = od.Item
      and dod.itemDescription = od.itemDescription
      and dod.[item Grp] = od.[item Grp]
      and wks.week = od.week

Open in new window

I think this may work (but I cannot test this assertion)

Author

Commented:
I renamed the tables within access to match them. I have re-attached the DB.

Then your query becomes below the match table names >>
select
        dod.Account
      , dod.Item
      , dod.itemDescription
      , dod.[item Grp]
      , wks.week
      , NZ(od.AmountL1,0)     AmountL1
      , NZ(od.AmountK2,0)     AmountK2
      , NZ(od.[dim Length],0) [dim Length]
      , NZ(od.WeekTY,0)       WeekTY
from (
      select distinct
              Account
            , Item
            , itemDescription
            , [item Grp]
            , CInt(null) AmountL1
            , CInt(null) AmountK2
            , CInt(null) [dim Length]
            , CInt(null) WeekTY
      from originalData
     ) dod, total_End_to_End_Weeks as wks
left join originalData od
      on  dod.Account = od.Account
      and dod.Item = od.Item
      and dod.itemDescription = od.itemDescription
      and dod.[item Grp] = od.[item Grp]
      and wks.week = od.week

Author

Commented:
still not working
PortletPaulEE Topic Advisor
CERTIFIED EXPERT
Most Valuable Expert 2014
Awarded 2013
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT

Commented:
In Access you can use sequental queries. Look at sample. Query qryAppend2 will add missing rows to your table. I've modified your table with weeks, because in text compare fweek2 > fweek10. I've added decimal number of week.
SampleDBPlease22.accdb

Author

Commented:
Thank you Portlet Paul, your logic makes sense.

Als315 – thank you your solution fits it. Can you explain how you did it?
Thanks again….this does what I wanted….
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
thank you all
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.