tomfolinsbee
asked on
What is wrong with my append query?
I'm getting this error message :You tried to assign the null value to a variable that is not a variant data type" when i run an append query.
The query worked fine in the past with smaller data sets - first time this has happened. No other changes to the query. I tried using top 1, but still get error. I changed to Select query and it worked fine. I checked the properties of all the table fields - no "Required" fields and "Allow zero length" is set to "YES" for all text fields. Any other suggestions?
The query worked fine in the past with smaller data sets - first time this has happened. No other changes to the query. I tried using top 1, but still get error. I changed to Select query and it worked fine. I checked the properties of all the table fields - no "Required" fields and "Allow zero length" is set to "YES" for all text fields. Any other suggestions?
post the sql of your append query
ASKER
INSERT INTO tblrptMonitorHeader ( ID, NameA, NameB, tblBloomberg_TICKER_AND_EX CH_CODE, tblBloomberg_1_TICKER_AND_ EXCH_CODE, NextAnnA, NextAnnB, [Day], [Avg], [Min], [Max], Win, Loss, Trade, Corr, DF, LastRatio, AvgRatio, StdevRatio, LastA, LastB, tblBloomberg_BEST_PE_RATIO , tblBloomberg_BEST_DIV_YLD, tblBloomberg_BEST_PX_BPS_R ATIO, tblBloomberg_1_BEST_PE_RAT IO, tblBloomberg_1_BEST_DIV_YL D, tblBloomberg_1_BEST_PX_BPS _RATIO, BEST_PEG_RATIOA, BEST_PEG_RATIOB, BEST_PX_SALES_RATIOA, BEST_PX_SALES_RATIOB, [EBIT%A], [EBIT%B], EQY_REC_CONSA, EQY_REC_CONSB, TOT_BUY_RECA, TOT_BUY_RECB, TOT_HOLD_RECA, TOT_HOLD_RECB, TOT_SELL_RECA, TOT_SELL_RECB, BEST_PX_CPS_RATIOA, BEST_PX_CPS_RATIOB, Spread_PE, Spread_PB, Spread_DY, ROA_A, ROE_A, ROA_B, ROE_B, Beta_A, Beta_B, tblBloomberg_Avg_Daily_Val ue_Traded_ 20D, tblBloomberg_1_Avg_Daily_V alue_Trade d_20D, MRG_A, MRG_B, RSI_A, RSI_B, TRR1_A, TRR1_B, TRR5_A, TRR5_B, 4WKUP_A, 4WKDN_A, 4WKUP_B, 4WKDN_B, MeanReturn, [%RatioChg], SideA, SideB, NDE_A, NDE_B, LastZ, AbsZ, IndustrySubGroupA, IndustrySubGroupB, PreviousZ, AbsPreviousZ, ChgAbsZ, COUNTRY_FULL_NAME, PositionOpenDays, StrategyA, StrategyB, StrategyRatio, CommentA, CommentB, Comment )
SELECT tf_RealisedReturnGroupByPa ir.PairID, tblBloomberg.SHORT_NAME AS NameA, tblBloomberg_1.SHORT_NAME AS NameB, tblBloomberg.TICKER_AND_EX CH_CODE, tblBloomberg_1.TICKER_AND_ EXCH_CODE, tblBloomberg.Expected_Repo rt_DT AS NextAnnA, tblBloomberg_1.Expected_Re port_DT AS NextAnnB, tf_RealisedReturnGroupByPa ir.Day, tf_RealisedReturnGroupByPa ir.Avg, tf_RealisedReturnGroupByPa ir.Min, tf_RealisedReturnGroupByPa ir.Max, tf_RealisedReturnGroupByPa ir.Win, tf_RealisedReturnGroupByPa ir.Loss, tf_RealisedReturnGroupByPa ir.Trade, tf_Statistic.Corr, tf_Statistic.DF, tf_Statistic.LastRatio, tf_Statistic.AvgRatio, tf_Statistic.StdevRatio, tblBloomberg.PX_LAST AS LastA, tblBloomberg_1.PX_LAST AS LastB, tblBloomberg.BEST_PE_RATIO , tblBloomberg.BEST_DIV_YLD, tblBloomberg.BEST_PX_BPS_R ATIO, tblBloomberg_1.BEST_PE_RAT IO, tblBloomberg_1.BEST_DIV_YL D, tblBloomberg_1.BEST_PX_BPS _RATIO, tblBloomberg.BEST_PEG_RATI O, tblBloomberg_1.BEST_PEG_RA TIO, tblBloomberg.BEST_PX_SALES _RATIO, tblBloomberg_1.BEST_PX_SAL ES_RATIO, tblBloomberg!BEST_EBIT/tbl Bloomberg! BEST_SALES AS [EBIT%A], tblBloomberg_1!BEST_EBIT/t blBloomber g_1!BEST_S ALES AS [EBIT%B], tblBloomberg.EQY_REC_CONS, tblBloomberg_1.EQY_REC_CON S, tblBloomberg.TOT_BUY_REC, tblBloomberg_1.TOT_BUY_REC , tblBloomberg.TOT_HOLD_REC, tblBloomberg_1.TOT_HOLD_RE C, tblBloomberg.TOT_SELL_REC, tblBloomberg_1.TOT_SELL_RE C, tblBloomberg.BEST_PX_CPS_R ATIO, tblBloomberg_1.BEST_PX_CPS _RATIO, Abs(tblBloomberg!BEST_PE_R ATIO-tblBl oomberg_1! BEST_PE_RA TIO) AS Spread_PE, Abs(tblBloomberg!BEST_PX_B PS_RATIO-t blBloomber g_1!BEST_P X_BPS_RATI O) AS Spread_PB, tblBloomberg!BEST_DIV_YLD- tblBloombe rg_1!BEST_ DIV_YLD AS Spread_DY, tblBloomberg.BEST_ROA AS ROA_A, tblBloomberg.BEST_ROE AS ROE_A, tblBloomberg_1.BEST_ROA AS ROA_B, tblBloomberg_1.BEST_ROE AS ROE_B, tblBloomberg.Eqy_Beta AS Beta_A, tblBloomberg_1.Eqy_Beta AS Beta_B, tblBloomberg.Avg_Daily_Val ue_Traded_ 20D, tblBloomberg_1.Avg_Daily_V alue_Trade d_20D, tblBloomberg.MRG_6M_RATIO AS MRG_A, tblBloomberg_1.MRG_6M_RATI O AS MRG_B, tblBloomberg.RSI_PX_52WEEK AS RSI_A, tblBloomberg_1.RSI_PX_52WE EK AS RSI_B, tblBloomberg.PREV_BUS_TRR_ 1DAY AS TRR1_A, tblBloomberg_1.PREV_BUS_TR R_1DAY AS TRR1_B, tblBloomberg.PREV_BUS_TRR_ 5DAY AS TRR5_A, tblBloomberg_1.PREV_BUS_TR R_5DAY AS TRR5_B, tblBloomberg.BEST_EPS_4WK_ UP AS 4WKUP_A, tblBloomberg.BEST_EPS_4WK_ DN AS 4WKDN_A, tblBloomberg_1.BEST_EPS_4W K_UP AS 4WKUP_B, tblBloomberg_1.BEST_EPS_4W K_DN AS 4WKDN_B, Abs(tf_Statistic!LastRatio /tf_Statis tic!AvgRat io-1) AS MeanReturn, tf_Statistic!LastRatio/tf_ Statistic_ PreviousDa y!LastRati o-1 AS [%RatioChg], IIf(tf_Statistic!Zscore<-2 ,"Long ",IIf(tf_Statistic!Zscore> 2,"Short ","")) AS SideA, IIf(tf_Statistic!Zscore<-2 ,"Short",I If(tf_Stat istic!Zsco re>2,"Long ","")) AS SideB, tblBloomberg.NET_DEBT_TO_S HRHLDR_EQT Y AS NDE_A, tblBloomberg_1.NET_DEBT_TO _SHRHLDR_E QTY AS NDE_B, tf_Statistic.Zscore, Abs(tf_Statistic!Zscore) AS AbsZ, tblBloomberg.INDUSTRY_SUBG ROUP, tblBloomberg_1.INDUSTRY_SU BGROUP, tf_Statistic_PreviousDay!Z score AS PreviousZ, Abs(tf_Statistic_PreviousD ay!Zscore) AS AbsPreviousZ, Abs(tf_Statistic!Zscore)-A bs(tf_Stat istic_Prev iousDay!Zs core) AS ChgAbsZ, tblBloomberg.COUNTRY_FULL_ NAME, Now()-tf_Statistic!Previou sTradeDate AS PositionOpenDays, IIf(tf_Statistic!LastRatio <tf_Statis tic!AvgRat io,"LONG " & tblBloomberg!SHORT_NAME & " (" & tblBloomberg!TICKER_AND_EX CH_CODE & ")","SHORT " & tblBloomberg!SHORT_NAME & "( " & tblBloomberg!TICKER_AND_EX CH_CODE & ")") AS StrategyA, IIf(tf_Statistic!LastRatio <tf_Statis tic!AvgRat io,"SHORT " & tblBloomberg_1!SHORT_NAME & "( " & tblBloomberg_1!TICKER_AND_ EXCH_CODE & ")","LONG " & tblBloomberg_1!SHORT_NAME & "( " & tblBloomberg_1!TICKER_AND_ EXCH_CODE & ")") AS StrategyB, IIf(tf_Statistic!LastRatio <tf_Statis tic!AvgRat io," Ratio " & Round(tf_Statistic!LastRat io,4) & " or lower"," Ratio " & Round(tf_Statistic!LastRat io,4) & " or higher") AS StrategyRatio, Comment.Comment, Comment_1.Comment, Pair.PublishComment
FROM (Comment RIGHT JOIN (tf_Statistic_PreviousDay INNER JOIN (tf_Statistic RIGHT JOIN (((tf_RealisedReturnGroupB yPair RIGHT JOIN Pair ON tf_RealisedReturnGroupByPa ir.PairID = Pair.ID) INNER JOIN tblBloomberg ON Pair.SecurityA = tblBloomberg.Ticker) INNER JOIN tblBloomberg AS tblBloomberg_1 ON Pair.SecurityB = tblBloomberg_1.Ticker) ON tf_Statistic.pairlistid = Pair.ID) ON tf_Statistic_PreviousDay.p airlistid = Pair.ID) ON Comment.SecurityID = Pair.SecurityA) LEFT JOIN Comment AS Comment_1 ON Pair.SecurityB = Comment_1.SecurityID
WHERE (((Pair.Monitor)=True))
ORDER BY Abs(tf_Statistic!Zscore) DESC;
SELECT tf_RealisedReturnGroupByPa
FROM (Comment RIGHT JOIN (tf_Statistic_PreviousDay INNER JOIN (tf_Statistic RIGHT JOIN (((tf_RealisedReturnGroupB
WHERE (((Pair.Monitor)=True))
ORDER BY Abs(tf_Statistic!Zscore) DESC;
No need for the query (sorry cap!).
> "You tried to assign the null value to a variable that is not a variant data type"
That is not a Jet error message, but a VB error message. It has nothing to do with your query. Even if your query did call a VB function, the message would not be displayed. It would result in #Error in the field, that's all.
Try the following:
* Switch to VB (Alt+F11)
* choose from the menu: (Tools | Options), [General], "Break on all errors"
* run your code again (e.g. press the button)
* when you see the error message, choose [Debug]
* look at the highlighted line (you can post it here if you like)
* DON'T FORGET: set back to:
(Tools | Options), [General], "Break on Unhandled errors"
Cheers!
(°v°)
> "You tried to assign the null value to a variable that is not a variant data type"
That is not a Jet error message, but a VB error message. It has nothing to do with your query. Even if your query did call a VB function, the message would not be displayed. It would result in #Error in the field, that's all.
Try the following:
* Switch to VB (Alt+F11)
* choose from the menu: (Tools | Options), [General], "Break on all errors"
* run your code again (e.g. press the button)
* when you see the error message, choose [Debug]
* look at the highlighted line (you can post it here if you like)
* DON'T FORGET: set back to:
(Tools | Options), [General], "Break on Unhandled errors"
Cheers!
(°v°)
ASKER
Thanks - tried that, but now the db crashes ... no error message though... just the "Sorry, MS Access has encountered a problem and has to shut down"...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the suggestions. Turns out the problem was the autonumber field in the table - I changed it to an integer, and the problem was resolved. Thanks again!