Opening query shuts access down

T

Tara

I have a query that is causing me huge headaches. It appears to run
perfectly when it's executed, but if I try to open it in design view, it
shuts access down completely! I have recreated it several times already.
I've imported everything into a brand new database twice. I realize it's a
large query and probably not the best way of achieving the results I want,
but I'm a novice to coding so this was the route I chose. At any rate, I
cannot figure out what the issue is. I've copied and pasted the query below
in hopes that somebody can help me figure this out.

SELECT tbl125.numIDNum, tbl125.dtmPlanStart, tbl125.strPlanType,
tbl125.ADJUSTEDStartDate, tbl125.curContrib, tbl125.curContribADJUSTED,
IIf([TerminationDate] Is Null And
[curContribADJUSTED]=0,Int((Date()-tbl125!dtmPlanStart)/14)*(tbl125!curContrib/tblWeeks!Weeks),IIf([TerminationDate]
Is Null And
[curContribADJUSTED]>0,Int(([ADJUSTEDStartDate]-tbl125!dtmPlanStart)/14)*(tbl125!curContrib/tblWeeks!Weeks)+Int((Date()-tbl125!ADJUSTEDStartDate)/14)*(tbl125!curContribADJUSTED/tblWeeks!Weeks),IIf([TerminationDate]
Is Not Null And
[curContribADJUSTED]=0,Int(([TerminationDate]-tbl125!dtmPlanStart)/14)*(tbl125!curContrib/tblWeeks!Weeks),IIf([TerminationDate]
Is Not Null And
[curContribADJUSTED]>0,Int(([TerminationDate]-tbl125!ADJUSTEDStartDate)/14)*(tbl125!curContribADJUSTED/tblWeeks!Weeks)+Int(([ADJUSTEDStartDate]-tbl125!dtmPlanStart)/14)*(tbl125!curContrib/tblWeeks!Weeks)))))
AS ytd,
IIf([curContribADJUSTED]=0,([curContrib]/tblWeeks!Weeks),IIf([curContribADJUSTED]>0,([curContribADJUSTED]/tblWeeks!Weeks),IIf([curCo
ntribADJUSTED]>0 And ([ytd]>[curContribADJUSTED]),0))) AS
[BiWeeklyWitholding], tblWeeks.Weeks, IIf([curContribADJUSTED]>0 And
([ytd]>[curContribADJUSTED]),0,[BiWeeklyWitholding]) AS [BiWeeklyWitholding2]
FROM (tblEmployee INNER JOIN tbl125 ON tblEmployee.numIdNum=tbl125.numIDNum)
INNER JOIN tblWeeks ON (tblEmployee.numIdNum=tblWeeks.numIDNum) AND
(tblEmployee.numIdNum=tblWeeks.numIDNum);



Also, I have a question about references. In order to get to the SQL view
(so I could copy and paste directly instead of recreating it again), I
created a new module and ran the following code:

Public Sub GetSQL()
Dim qry As QueryDef
Set qry = CurrentDb.QueryDefs("qry125YTD")
Debug.Print qry.SQL
End Sub

BUT, everytime I do this I have to go back in and select the Microsoft DAO
3.6 Object Library reference. Once I select it, shouldn't it stay selected?

Any help is greatly appreciated!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top