gigifarrow
asked on
How to I work around in query in SQL expression Exceeds 1,024 charactor limit in query grid design
I have a code that gives check marks values based on the production number. The code works fine. but when I go into to design view i get a message that the expression is exceeds 1,024 character limit. How do i change the code to comply with the character limit?
IIf([Production]>=168 OR [Production]<=128,
Abs(([tblFortCarsonFullup] ![Inductio n]*5+[tblF ortCarsonF ullup]![De fuel]*1+[t blFortCars onFullup]! [TurretPul l]*10+[tbl FortCarson Fullup]![F uelCellRem oved]*10+[ tblFortCar sonFullup] ![BFCSProv ision]*5+[ tblFortCar sonFullup] ![ERR]*10+ [tblFortCa rsonFullup ]![TASS]*1 0+[tblFort CarsonFull up]![BASSD Provision] *0+[tblFor tCarsonFul lup]![BASS DInstalled ]*0+[tblFo rtCarsonFu llup]![BFC SInstalled ]*10+[tblF ortCarsonF ullup]![Tu rretInstal led]*10+[t blFortCars onFullup]! [E1Ground] *1+[tblFor tCarsonFul lup]![Driv erSeatSpac er]*0+[tbl FortCarson Fullup]![G unnersSeat Stop]*1+[t blFortCars onFullup]! [AFESSwitc hGuard]*1+ [tblFortCa rsonFullup ]![ReliefH oleExtingu isher]*1+[ tblFortCar sonFullup ]![25mmHotBox]*2+[tblFortC arsonFullu p]![ErrHan dleMod]*0+ [tblFortCa rsonFullup ]![ACS]*1+ [tblFortCa rsonFullup ]![FuelShu toffSleeve ]*1+[tblFo rtCarsonFu llup]![Fin alQAQC]*11 +[tblFortC arsonFullu p]![Outduc tion]*10)/ 100)*100,( Abs(([tblF ortCarsonF ullup]![In duction]*5 +[tblFortC arsonFullu p]![Defuel ]*1+[tblFo rtCarsonFu llup]![Tur retPull]*1 0+[tblFort CarsonFull up]![FuelC ellRemoved ]*10+[tblF ortCarsonF ullup]![BF CSProvisio n]*5+[tblF ortCarsonF ullup]![ER R]*10+[tbl FortCarson Fullup]![T ASS]*10+[t blFortCars onFullup]! [BASSDProv ision]*0+[ tblFortCar sonFullup] ![BASSDIns talled]*0+ [tblFortCa rsonFullup ]![BFCSIns talled]*10 +[tblFortC arsonFullu p]![Turret Installed] *10+[tblFo rtCarsonFu llup]![E1G round]*1+[ tblFortCar sonFullup] ![DriverSe atSpacer]* 0+[tblFort CarsonFull up]![Gunne rsSeatStop ]*1+[tblFo rtCarsonFu llup]![AFE SSwitchGua rd]*1+[tbl FortCarson Fullup]![R eliefHoleE xtinguishe r]*1+[tblF ortCarsonF ullup ]![25mmHotBox]*2+[tblFortC arsonFullu p]![ErrHan dleMod]*0+ [tblFortCa rsonFullup ]![ACS]*1+ [tblFortCa rsonFullup ]![FuelShu toffSleeve ]*1+[tblFo rtCarsonFu llup]![Fin alQAQC]*11 +[tblFortC arsonFullu p]![Outduc tion]*20)/ 100)*100)) AS PercentagesFortCarsonB
FROM tblFortCarsonFullup;
IIf([Production]>=168 OR [Production]<=128,
Abs(([tblFortCarsonFullup]
FROM tblFortCarsonFullup;
try removing "[tblFortCarsonFullup]!" from the query
or
go to the table [tblFortCarsonFullup] property and give an alias name F to the table
so your query will look like this
IIf([Production]>=168 OR [Production]<=128,
Abs((F![Induction]*5+F![De fuel]*1+F! [TurretPul l]*10+F![F uelCellRem oved]*10+F ![BFCSProv ision]*5+F ![ERR]*10+ F![TASS]*1 0+F![BASSD Provision] *0+F![BASS DInstalled ]*0+F![BFC SInstalled ]*10+F![Tu rretInstal led]*10+F! [E1Ground] *1+F![Driv erSeatSpac er]*0+F![G unnersSeat Stop]*1+F! [AFESSwitc hGuard]*1+ F![ReliefH oleExtingu isher]*1+F ![25mmHotB ox]*2+F![E rrHandleMo d]*0+F![AC S]*1+F![Fu elShutoffS leeve]*1+F ![FinalQAQ C]*11+F![O utduction] *10)/100)* 100,(Abs(( F![Inducti on]*5+F![D efuel]*1+F ![TurretPu ll]*10+F![ FuelCellRe moved]*10+ F![BFCSPro vision]*5+ F![ERR]*10 +F![TASS]* 10+F![BASS DProvision ]*0+F![BAS SDInstalle d]*0+F![BF CSInstalle d]*10+F![T urretInsta lled]*10+F ![E1Ground ]*1+F![Dri verSeatSpa cer]*0+F![ GunnersSea tStop]*1+F ![AFESSwit chGuard]*1 +F![Relief HoleExting uisher]*1+ F![25mmHot Box]*2+F![ ErrHandleM od]*0+F![A CS]*1+F![F uelShutoff Sleeve]*1+ F![FinalQA QC]*11+F![ Outduction ]*20)/100) *100)) AS PercentagesFortCarsonB
FROM tblFortCarsonFullup As F;
or
go to the table [tblFortCarsonFullup] property and give an alias name F to the table
so your query will look like this
IIf([Production]>=168 OR [Production]<=128,
Abs((F![Induction]*5+F![De
FROM tblFortCarsonFullup As F;
ASKER
Thanks for all you comments and advice. Also for taking the time to answer me .
Capricorn1 How do you give your table an alias name? Do I just go ahead and rename the table. If thats the case I will have to go into all my code and change the name.
Jdettman: I havent really dealed with functions before. Do I declare a function in the query in the sql design? could you please elaborate on how i would do this.
Capricorn1 How do you give your table an alias name? Do I just go ahead and rename the table. If thats the case I will have to go into all my code and change the name.
Jdettman: I havent really dealed with functions before. Do I declare a function in the query in the sql design? could you please elaborate on how i would do this.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
<<Jdettman: I havent really dealed with functions before. Do I declare a function in the query in the sql design? could you please elaborate on how i would do this. >>
In Access, procedures are placed in code modules. Not sure which version your using, but you'd create a standard module and then do:
Public Function myCalculation(varInput as variant) as double
' Do calculations here
myCalculation =
End Function
and save the module. Then call it from the query.
You would need to pass in all the values from the query that you need for the calculation.
Often using a procedure can help keep logic clear when the calculation is complex and it's also good to use when you need data outside of what's in the query.
For this situation, cap's suggestion of shortening the table name is probably a good way to get around the error.
but if your going to add more to this calculation, then you may need to move it into a function even though your using a short alias.
Jim.
In Access, procedures are placed in code modules. Not sure which version your using, but you'd create a standard module and then do:
Public Function myCalculation(varInput as variant) as double
' Do calculations here
myCalculation =
End Function
and save the module. Then call it from the query.
You would need to pass in all the values from the query that you need for the calculation.
Often using a procedure can help keep logic clear when the calculation is complex and it's also good to use when you need data outside of what's in the query.
For this situation, cap's suggestion of shortening the table name is probably a good way to get around the error.
but if your going to add more to this calculation, then you may need to move it into a function even though your using a short alias.
Jim.
MyFunctioName(<somefieldna
You need to pass an argument even if it's not used so that the function is called for every row of the query.
Jim.