English 中文(简体)
简称表
原标题:MS ACCESS- Editing and undoing SQL causes error
  • 时间:2012-05-16 11:05:42
  •  标签:
  • ms-access

I have a query (equivalent of View in ORACLE, SQL Server) that I saved in an Access database. Now I need to add another column to my select list. But whenever I change the SQL I get errors. Let s say I remove one comma and then put it back. I get errors like "Syntax error after From","Syntax error in Join operation". So if I change anything and then undo the change I still get errors. How can I avoid this?

Edit:Before Editor

SELECT A_B.ALICI, Q.QAINOM, M.TIP, Q.QATARIX, Q.CEMIBORC, R2.ADI AS SAT_NOV, M.TAMADI, M.MARK, SA.MIQDAR, SA.SAQIYM, SA.CEMI, SA.FAIZ, A_B.BORC_SU, A_B.MEBLEG, A_B.FERQ, K_G.CEMI_ODEN, A_B.MOBTEL, SA.NOTE
FROM ([SELECT  Round(Sum([DBKASSA].[MEBLEQ]),3) AS CEMI_ODEN, DBKASSA.KODAL_GT
FROM DBKASSA
WHERE (((DBKASSA.TIP)=1) AND ((DBKASSA.KODAL_GT)=[INBUYERID]) AND ((DBKASSA.TARIX)=[INTILLDATE]))
GROUP BY DBKASSA.KODAL_GT]. AS K_G RIGHT JOIN ([SELECT AL.KODALAN,AL.MOBTEL, IIf([Su_CEMIBORC] Is Null,0,[Su_CEMIBORC]) AS BORC_SU, IIf([Su_MEBLEQ] Is Null,0,[Su_MEBLEQ]) AS MEBLEG, (IIf([Su_MEBLEQ] Is Null,0,[Su_MEBLEQ]))-(IIf([Su_CEMIBORC] Is Null,0,[Su_CEMIBORC])) AS FERQ, AL!OBYEKT & (IIf(AL!NUMAY Is Not Null," - " & AL!NUMAY)) AS ALICI
FROM 
 (
   SELECT DBKASSA.KODAL_GT, Sum(DBKASSA.MEBLEQ) AS Su_MEBLEQ
   FROM DBKASSA
   WHERE (((DBKASSA.TIP)=1) AND ((DBKASSA.KODAL_GT)=[INBUYERID]))
   GROUP BY DBKASSA.KODAL_GT
   ) AS OD_AL 
    RIGHT JOIN (
    (
    SELECT DBQAIME.KODALAN, Sum(DBQAIME.CEMIBORC) AS Su_CEMIBORC
    FROM DBQAIME
    WHERE (((DBQAIME.KODALAN)=[INBUYERID]))
    GROUP BY DBQAIME.KODALAN
    ) AS B_AL 
    RIGHT JOIN DBALAN AS AL ON B_AL.KODALAN = AL.KODALAN) ON OD_AL.KODAL_GT = AL.KODALAN
    WHERE (((AL.KODALAN)=[INBUYERID]))
 ]. AS A_B INNER JOIN DBQAIME AS Q ON A_B.KODALAN = Q.KODALAN) ON K_G.KODAL_GT = A_B.KODALAN) INNER JOIN (DBMAL AS M INNER JOIN (DBSA AS SA INNER JOIN [SELECT R2.KOD, R2.VID, R2.ADI
   FROM DBRAB2 AS R2
   WHERE (((R2.VID)=3))]. AS R2 ON SA.KODEMLNO = R2.KOD) ON M.KODMAL = SA.KODMAL) ON Q.QAINOM = SA.QAINOM
WHERE (((Q.QAINOM)=[INSALEINVOICE]))
ORDER BY M.TIP, M.TAMADI;

编辑后;

SELECT A_B.ALICI, Q.QAINOM, M.TIP, Q.QATARIX, Q.CEMIBORC, R2.ADI AS SAT_NOV, M.TAMADI, M.MARK, SA.MIQDAR, SA.SAQIYM, SA.CEMI, SA.FAIZ, A_B.BORC_SU, A_B.MEBLEG, A_B.FERQ, K_G.CEMI_ODEN, A_B.MOBTEL, SA.NOTE
FROM ([SELECT  Round(Sum([DBKASSA].[MEBLEQ]),3) AS CEMI_ODEN, DBKASSA.KODAL_GT
FROM DBKASSA
WHERE (((DBKASSA.TIP)=1) AND ((DBKASSA.KODAL_GT)=[INBUYERID]) AND ((DBKASSA.TARIX)=[INTILLDATE]))
GROUP BY DBKASSA.KODAL_GT]. AS K_G RIGHT JOIN ([SELECT AL.KODALAN,AL.MOBTEL, IIf([Su_CEMIBORC] Is Null,0,[Su_CEMIBORC]) AS BORC_SU, IIf([Su_MEBLEQ] Is Null,0,[Su_MEBLEQ]) AS MEBLEG, (IIf([Su_MEBLEQ] Is Null,0,[Su_MEBLEQ]))-(IIf([Su_CEMIBORC] Is Null,0,[Su_CEMIBORC])) AS FERQ, AL!OBYEKT & (IIf(AL!NUMAY Is Not Null," - " & AL!NUMAY)) AS ALICI
FROM 
 (
   SELECT DBKASSA.KODAL_GT, Sum(DBKASSA.MEBLEQ) AS Su_MEBLEQ
   FROM DBKASSA
   WHERE (((DBKASSA.TIP)=1) AND ((DBKASSA.KODAL_GT)=[INBUYERID]))
   GROUP BY DBKASSA.KODAL_GT
   ) AS OD_AL 
    RIGHT JOIN (
    (
    SELECT DBQAIME.KODALAN, Sum(DBQAIME.CEMIBORC) AS Su_CEMIBORC
    FROM DBQAIME
    WHERE (((DBQAIME.KODALAN)=[INBUYERID]))
    GROUP BY DBQAIME.KODALAN
    ) AS B_AL 
    RIGHT JOIN DBALAN AS AL ON B_AL.KODALAN = AL.KODALAN) ON OD_AL.KODAL_GT = AL.KODALAN
    WHERE (((AL.KODALAN)=[INBUYERID]))
 ]. AS A_B INNER JOIN DBQAIME AS Q ON A_B.KODALAN = Q.KODALAN) ON K_G.KODAL_GT = A_B.KODALAN) INNER JOIN (DBMAL AS M INNER JOIN (DBSA AS SA INNER JOIN [SELECT R2.KOD, R2.VID, R2.ADI
   FROM DBRAB2 AS R2
   WHERE (((R2.VID)=3))]. AS R2 ON SA.KODEMLNO = R2.KOD) ON M.KODMAL = SA.KODMAL) ON Q.QAINOM = SA.QAINOM
WHERE (((Q.QAINOM)=[INSALEINVOICE]))
ORDER BY M.TIP, M.TAMADI;

这样,它就在2010年获得管理服务。 2003年获得地雷

问题回答

实际情况是,你的子座或衍生的桌子现在像现在这样放在括号内。

[stuff here].

造成编辑错误。

最容易做的是使用笔记或像这样的笔记,将[]改为(])和背后。

Try:

SELECT A_B.ALICI,
       Q.QAINOM,
       M.TIP,
       Q.QATARIX,
       Q.CEMIBORC,
       R2.ADI AS SAT_NOV,
       M.TAMADI,
       M.MARK,
       SA.MIQDAR,
       SA.SAQIYM,
       SA.CEMI,
       SA.FAIZ,
       A_B.BORC_SU,
       A_B.MEBLEG,
       A_B.FERQ,
       K_G.CEMI_ODEN,
       A_B.MOBTEL,
       SA.NOTE
FROM   ((SELECT Round(SUM([DBKASSA].[MEBLEQ]), 3) AS CEMI_ODEN,
               DBKASSA.KODAL_GT
        FROM   DBKASSA
        WHERE  ( ( ( DBKASSA.TIP ) = 1 )
                 AND ( ( DBKASSA.KODAL_GT ) = [INBUYERID] )
                 AND ( ( DBKASSA.TARIX ) = [INTILLDATE] ) )
        GROUP  BY DBKASSA.KODAL_GT) AS K_G
        RIGHT JOIN ((SELECT AL.KODALAN,
                           AL.MOBTEL,
                           Iif([Su_CEMIBORC] IS NULL, 0, [Su_CEMIBORC])
                                                                AS
                            BORC_SU,
                           Iif([Su_MEBLEQ] IS NULL, 0, [Su_MEBLEQ])
                                                                AS
                            MEBLEG,
                           ( Iif([Su_MEBLEQ] IS NULL, 0, [Su_MEBLEQ]) ) - (
                           Iif([Su_CEMIBORC] IS NULL, 0, [Su_CEMIBORC]) )
                                                                AS
                                                                           FERQ,
                           AL ! OBYEKT & ( Iif(AL ! NUMAY IS NOT NULL,
                                           " - " & AL ! NUMAY) ) AS
                                               ALICI
                    FROM   (SELECT DBKASSA.KODAL_GT,
                                   SUM(DBKASSA.MEBLEQ) AS Su_MEBLEQ
                            FROM   DBKASSA
                            WHERE
                    ( ( ( DBKASSA.TIP ) = 1 )
                      AND ( ( DBKASSA.KODAL_GT ) = [INBUYERID] ) )
                            GROUP  BY DBKASSA.KODAL_GT) AS OD_AL
                           RIGHT JOIN ( (SELECT DBQAIME.KODALAN,
                                              SUM(DBQAIME.CEMIBORC) AS
                                                Su_CEMIBORC
                                       FROM   DBQAIME
                                       WHERE  ((
                                      ( DBQAIME.KODALAN ) = [INBUYERID] ))
                                       GROUP  BY DBQAIME.KODALAN) AS B_AL
                                        RIGHT JOIN DBALAN AS AL
                                          ON B_AL.KODALAN = AL.KODALAN)
                             ON OD_AL.KODAL_GT = AL.KODALAN
                    WHERE  (( ( AL.KODALAN ) = [INBUYERID] ))) AS A_B
                    INNER JOIN DBQAIME AS Q
                      ON A_B.KODALAN = Q.KODALAN)
          ON K_G.KODAL_GT = A_B.KODALAN)
       INNER JOIN (DBMAL AS M
                   INNER JOIN (DBSA AS SA
                               INNER JOIN (SELECT R2.KOD,
                                                  R2.VID,
                                                  R2.ADI
                                           FROM   DBRAB2 AS R2
                                           WHERE  (( ( R2.VID ) = 3 ))) AS R2
                                 ON SA.KODEMLNO = R2.KOD)
                     ON M.KODMAL = SA.KODMAL)
         ON Q.QAINOM = SA.QAINOM
WHERE  (( ( Q.QAINOM ) = [INSALEINVOICE] ))
ORDER  BY M.TIP,
          M.TAMADI; 




相关问题
Handling no results for docmd.applyfilter

I have an Access app where I use search functionality. I have a TextBox and a Search Button on the form, and it does a wildcard search of whatever the user enters in the TextBox, and displays the ...

access query to filter and combine count

i have two access tables tableA num count 1 7 2 8 3 9 4 9 5 13 6 6 tableB num count 0 1 1 14 2 12 3 5 4 5 5 11 6 5 how can i create an access query that ...

How to show File Picker dialog in Access 2007?

I want to show a dialog where the user can pick a file, click OK, and then the path to the file will be saved in the database. I have just one problem, I can t figure out how tho show the dialog ...

MS Access: list macro from VBA

I have to deal with a few macros (not VBA) in an inherited Access application. In order to document them, I would like to print or list the actions in those macros, but I am very dissatisfied by ...

Returning row number on MS Access

I have 4 tables, from which i select data with help of joins in select query...I want a serial no.(row number) per record as they are fetched. first fetched record should be 1, next 2 and so on... In ...

热门标签