Link to home
Create AccountLog in
Avatar of gigifarrow
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]![Induction]*5+[tblFortCarsonFullup]![Defuel]*1+[tblFortCarsonFullup]![TurretPull]*10+[tblFortCarsonFullup]![FuelCellRemoved]*10+[tblFortCarsonFullup]![BFCSProvision]*5+[tblFortCarsonFullup]![ERR]*10+[tblFortCarsonFullup]![TASS]*10+[tblFortCarsonFullup]![BASSDProvision]*0+[tblFortCarsonFullup]![BASSDInstalled]*0+[tblFortCarsonFullup]![BFCSInstalled]*10+[tblFortCarsonFullup]![TurretInstalled]*10+[tblFortCarsonFullup]![E1Ground]*1+[tblFortCarsonFullup]![DriverSeatSpacer]*0+[tblFortCarsonFullup]![GunnersSeatStop]*1+[tblFortCarsonFullup]![AFESSwitchGuard]*1+[tblFortCarsonFullup]![ReliefHoleExtinguisher]*1+[tblFortCarsonFullup ]![25mmHotBox]*2+[tblFortCarsonFullup]![ErrHandleMod]*0+[tblFortCarsonFullup]![ACS]*1+[tblFortCarsonFullup]![FuelShutoffSleeve]*1+[tblFortCarsonFullup]![FinalQAQC]*11+[tblFortCarsonFullup]![Outduction]*10)/100)*100,(Abs(([tblFortCarsonFullup]![Induction]*5+[tblFortCarsonFullup]![Defuel]*1+[tblFortCarsonFullup]![TurretPull]*10+[tblFortCarsonFullup]![FuelCellRemoved]*10+[tblFortCarsonFullup]![BFCSProvision]*5+[tblFortCarsonFullup]![ERR]*10+[tblFortCarsonFullup]![TASS]*10+[tblFortCarsonFullup]![BASSDProvision]*0+[tblFortCarsonFullup]![BASSDInstalled]*0+[tblFortCarsonFullup]![BFCSInstalled]*10+[tblFortCarsonFullup]![TurretInstalled]*10+[tblFortCarsonFullup]![E1Ground]*1+[tblFortCarsonFullup]![DriverSeatSpacer]*0+[tblFortCarsonFullup]![GunnersSeatStop]*1+[tblFortCarsonFullup]![AFESSwitchGuard]*1+[tblFortCarsonFullup]![ReliefHoleExtinguisher]*1+[tblFortCarsonFullup ]![25mmHotBox]*2+[tblFortCarsonFullup]![ErrHandleMod]*0+[tblFortCarsonFullup]![ACS]*1+[tblFortCarsonFullup]![FuelShutoffSleeve]*1+[tblFortCarsonFullup]![FinalQAQC]*11+[tblFortCarsonFullup]![Outduction]*20)/100)*100))AS PercentagesFortCarsonB
FROM tblFortCarsonFullup;
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Move the code into a public function, then call the function from the query like:

MyFunctioName(<somefieldname>)

 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.
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![Defuel]*1+F![TurretPull]*10+F![FuelCellRemoved]*10+F![BFCSProvision]*5+F![ERR]*10+F![TASS]*10+F![BASSDProvision]*0+F![BASSDInstalled]*0+F![BFCSInstalled]*10+F![TurretInstalled]*10+F![E1Ground]*1+F![DriverSeatSpacer]*0+F![GunnersSeatStop]*1+F![AFESSwitchGuard]*1+F![ReliefHoleExtinguisher]*1+F![25mmHotBox]*2+F![ErrHandleMod]*0+F![ACS]*1+F![FuelShutoffSleeve]*1+F![FinalQAQC]*11+F![Outduction]*10)/100)*100,(Abs((F![Induction]*5+F![Defuel]*1+F![TurretPull]*10+F![FuelCellRemoved]*10+F![BFCSProvision]*5+F![ERR]*10+F![TASS]*10+F![BASSDProvision]*0+F![BASSDInstalled]*0+F![BFCSInstalled]*10+F![TurretInstalled]*10+F![E1Ground]*1+F![DriverSeatSpacer]*0+F![GunnersSeatStop]*1+F![AFESSwitchGuard]*1+F![ReliefHoleExtinguisher]*1+F![25mmHotBox]*2+F![ErrHandleMod]*0+F![ACS]*1+F![FuelShutoffSleeve]*1+F![FinalQAQC]*11+F![Outduction]*20)/100)*100)) AS PercentagesFortCarsonB
FROM tblFortCarsonFullup As F;
Avatar of gigifarrow
gigifarrow

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.
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
<<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.