Query problems (1 Viewer)

endri81

Registered User.
Local time
Today, 09:44
Joined
Jul 5, 2010
Messages
121
Hi,
Using this query I am having syntax problems.
Being a beginner can you please help me identify the query problems and making it work for me?

Regards


SELECT District.Id, District.Emer AS Rrethi, Data_SDP.Ref_SDP, SDP.Emri AS QPF, [Mg1]+[Mg2]-[Mg3]-[Mg4_t]-[Mg5] AS Mg4, [Mcv1]+[Mcv2]-[Mcv3]-[Mcv4_t]-[Mcv5] AS Mcv4, [Depo1]+[Depo2]-[Depo3]-[Depo4_t]-[Depo5] AS Depo4, [DIU1]+[DIU2]-[DIU3]-[DIU4_t]-[DIU5] AS DIU4, [Cn1]+[Cn2]-[Cn3]-[Cn4_t]-[Cn5] AS Cn4, datepart("q",[Data e fillimit te tremujorit]) & year([Data e fillimit te tremujorit]) as PeriodQuarter,clng(IIF(left(PeriodQuarter,1) in (2,3),"1" & year([Data e fillimit te tremujorit]),iif(left(periodquarter,1)=4,"2" & year([Data e fillimit te tremujorit]), "2" & year([Data e fillimit te tremujorit])-1))) as PeriodSemiAnnual,
SDP INNER JOIN (Data_SDP INNER JOIN District ON Data_SDP.Ref_District = District.Id) ON SDP.Id = Data_SDP.Ref_SDP
WHERE (((Data_SDP.[Data e fillimit te tremujorit])=[Forms]![raporte_te_tjera]![Jepni Daten e fillimit te tremujorit]))
GROUP BY District.Id, District.Emer, Data_SDP.Ref_SDP, SDP.Emri, [Mg1]+[Mg2]-[Mg3]-[Mg4_t]-[Mg5], [Mcv1]+[Mcv2]-[Mcv3]-[Mcv4_t]-[Mcv5], [Depo1]+[Depo2]-[Depo3]-[Depo4_t]-[Depo5], [DIU1]+[DIU2]-[DIU3]-[DIU4_t]-[DIU5], [Cn1]+[Cn2]-[Cn3]-[Cn4_t]-[Cn5]
HAVING ((([Mg1]+[Mg2]-[Mg3]-[Mg4_t]-[Mg5])<>0)) OR ((([Mcv1]+[Mcv2]-[Mcv3]-[Mcv4_t]-[Mcv5])<>0)) OR ((([Depo1]+[Depo2]-[Depo3]-[Depo4_t]-[Depo5])<>0)) OR ((([DIU1]+[DIU2]-[DIU3]-[DIU4_t]-[DIU5])<>0)) OR ((([Cn1]+[Cn2]-[Cn3]-[Cn4_t]-[Cn5])<>0))
ORDER BY District.Emer, SDP.Emri;
 

spikepl

Eledittingent Beliped
Local time
Today, 18:44
Joined
Nov 3, 2010
Messages
6,142
Build your query one step at a time.

Start with the SELECT only and start adding fields, one at a time. Then the expressions, one at a time. Then the join, then the missing fields. Then conditions/grouping. One at a time. Anything gives you trouble, then make a separate query with just that element and make it work. Once that works you can copy it into your query.

When you post questions concerning errors, list the error messages, or else the readers have to waste their time guessing.
 

endri81

Registered User.
Local time
Today, 09:44
Joined
Jul 5, 2010
Messages
121
Thank you for the fast reply.
Can you please help in specific case listed above.
Error is like in the picture attached
Regards
 

Attachments

  • pic1.jpg
    pic1.jpg
    86.3 KB · Views: 82

spikepl

Eledittingent Beliped
Local time
Today, 18:44
Joined
Nov 3, 2010
Messages
6,142
Is the form open when you run the query? Your refer to a control on a form: does it hold a value?
 

endri81

Registered User.
Local time
Today, 09:44
Joined
Jul 5, 2010
Messages
121
No the form is closed and control holds value Date().
For me is ok if I dont use at all
WHERE (((Data_SDP.[Data e fillimit te tremujorit])=[Forms]![raporte_te_tjera]![Jepni Daten e fillimit te tremujorit]))
but don't know how to modify query work even without that.
Regards

 

Users who are viewing this thread

Top Bottom