我有一个计算员工周年日期的查询。我希望该查询根据当前日期为我的表生成一个条目事件。在他们的周年日期到来时,基本上自动生成周年假期应计。这是我的表的一个例子。
Table name "SchedulingLog"
LogID "PrimaryKey AutoNbr"
UserID "Employee specific"
LogDate
EventDate
Category "ex Vacation, Anniversary..."
CatDetail "ex. Vacation Day Used, Anniversary..."
Value "ex. -1, 1..."
我的查询
Query Name "qry_YOS"
UserID "Employee Specific"
DOH "Employee hire date"
YearsOfService "calculated Field"
Annual "calculated Field"
Schedule "Employee Specific"
Annual Vac Days "calculated field"
Anniversary "calculated Field"
查询关联的SQL
INSERT INTO schedulinglog
(userid,
[value],
eventdate,
logdate,
category,
catdetail)
SELECT roster.userid,
[annual] * [schedule] AS [Value],
Month([wm doh]) & "/" & Day([wm doh]) & "/" & Year(DATE()) AS EventDate,
DATE() AS LogDate,
category.[category name] AS Category,
catdetail.catdetail
FROM roster,
tblaccrual,
category
INNER JOIN catdetail
ON category.categoryid = catdetail.categoryid
WHERE (( ( [tblaccrual] ! [years] ) < Round(( DATE() - [wm doh] ) / 365, 2) ))
GROUP BY roster.userid,
roster.[wm doh],
Round(( DATE() - [wm doh] ) / 365, 2),
roster.schedule,
Month([wm doh]) & "/" & Day([wm doh]) & "/" & Year(DATE()),
DATE(),
category.[category name],
catdetail.catdetail
HAVING ( ( ( category.[category name] ) LIKE "vacation*" )
AND ( ( catdetail.catdetail ) LIKE "anniversary*" ) );
我知道我可能不知道从哪里开始。
答案 0 :(得分:1)
使用查询设计窗口,将保存的查询添加到网格中,然后从工具栏中选择“附加”。选择要添加结果的表格,最终会得到类似的结果:
INSERT INTO Table1 ( AText2, ANumber )
SELECT Query1.AText2, Query1.Total
FROM Query1;
您可以触发查询以在事件上运行或要求用户单击按钮。