1

我有一个计算员工周年日期的查询。我希望该查询根据当前日期为我的表生成一个条目事件。当他们的周年纪念日到来时,基本上会自动生成周年假期累积。这是我的桌子的一个例子。

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*" ) ); 

我知道有可能我只是不知道从哪里开始。

4

1 回答 1

1

使用查询设计窗口,将保存的查询添加到网格并从工具栏中选择追加。选择要添加结果的表,您最终会得到类似的结果:

 INSERT INTO Table1 ( AText2, ANumber ) 
 SELECT Query1.AText2, Query1.Total 
 FROM Query1;

您可以触发查询以在事件上运行或要求用户单击按钮。

于 2012-12-18T17:02:26.720 回答