У меня есть форма с двумя текстовыми полями и двумя кнопками cmd (одну для поиска, а другую для удаления)
Когда я ввожу две даты, запрос на объединение работает хорошо (см. Qry4). Смотрите код ниже:
SELECT tblwrkday2.DATE, tblwrkday2.name, tblwrkday2.qty
FROM tblwrkday2
WHERE (((tblwrkday2.DATE) BETWEEN [Forms] ! [frm_Search] ! [txtday1]
AND [Forms] ! [frm_Search] ! [txtday2]))
ORDER BY tblwrkday2.name
UNION
SELECT tblwrkdays3.DATE, tblwrkdays3.name, tblwrkdays3.qty
FROM tblwrkdays3
WHERE (((tblwrkdays3.DATE) BETWEEN [Forms] ! [frm_Search] ! [txtday1]
AND [Forms] ! [frm_Search] ! [txtday2]));
Однако мне нужны данные, как показано в «qry4_expected».
Я безуспешно искал в Интернете.
Любая помощь приветствуется.
Первый код:
SELECT columns
FROM tblwrkday2
WHERE (((tblwrkday2.Date) Between [Formularios]![frm_Search]![txtday1] And [Formularios]![frm_Search]![txtday2]))
ORDER BY tblwrkday2.Datte
ORDER BY tblwrkday2.name
UNION SELECT tblwrkdays3.Date, tblwrkdays3.name, tblwrkdays3.qty
FROM tblwrkdays3
WHERE (((tblwrkdays3.Date) Between [Formularios]![frm_Search]![txtday1] And [Formularios]![frm_Search]![txtday2]));
Мой второй код:
SELECT columns
FROM tblwrkday2
WHERE (((tblwrkday2.Date) Between [Formularios]![frm_Search]![txtday1] And [Formularios]![frm_Search]![txtday2]))
ORDER BY tblwrkday2.Datte
ORDER BY tblwrkday2.name
UNION SELECT tblwrkdays3.Date, tblwrkdays3.name, tblwrkdays3.qty
FROM tblwrkdays3
WHERE (((tblwrkdays3.Date) Between [Formularios]![frm_Search]![txtday1] And [Formularios]![frm_Search]![txtday2]));
Мой третий код
SELECT columns
FROM tblwrkday2
WHERE (((tblwrkday2.Date) Between [Formularios]![frm_Search]![txtday1] And [Formularios]![frm_Search]![txtday2]))
ORDER BY tblwrkday2.Datte AND ORDER BY tblwrkday2.name
UNION SELECT tblwrkdays3.Date, tblwrkdays3.name, tblwrkdays3.qty
FROM tblwrkdays3
WHERE (((tblwrkdays3.Date) Between [Formularios]![frm_Search]![txtday1] And [Formularios]![frm_Search]![txtday2]));
Все SQL не удалось отобразить данные, как показано на правой стороне изображения.
Любая идея приветствуется.
Наконец я нашел код. Я перемещаю имя столбца влево, и запрос работает. Это код SQL:
SELECT tblwrkday2.name, tblwrkday2.Datte, tblwrkday2.qty
FROM tblwrkday2
WHERE (((tblwrkday2.Datte) Between [Forms]![frm_Search]![txtday1] And [Forms]![frm_Search]![txtday2]))
ORDER BY tblwrkday2.name
UNION SELECT tblwrkdays3.name, tblwrkdays3.Datte, tblwrkdays3.qty
FROM tblwrkdays3
WHERE (((tblwrkdays3.Datte) Between [Forms]![frm_Search]![txtday1] And [Forms]![frm_Search]![txtday2]));