我希望有人可以指出正确的方向。我想发生的是,当用户单击命令按钮时,它将首先删除GANTT_Setup_Table中的所有记录,然后将查询Tasks_table并根据今天的日期标准(TaskDate = date,返回UserID,TaskTypeID,Start_Time,End_Time) ())到GANTT_Setup表。最后,它将打开基于以下查询设置表的交叉表查询的报告。
现在,GANTT可以正常工作,因为它返回TaskTypeID并通过条件格式转换为适当的颜色。但是,它仅填写与start_time对应的txtbox,而不填写计划的其余时间或end_time。这是因为我根本不知道如何填写start_time和end_time之间的其他框。
交叉表:
TRANSFORM Max(GANTT_Setup_Table.[TaskTypeID]) AS MaxOfTaskTypeID
SELECT GANTT_Setup_Table.[UserID], Max(GANTT_Setup_Table.[TaskTypeID]) AS [Total Of TaskTypeID]
FROM GANTT_Setup_Table
WHERE TaskDate =Date()
GROUP BY GANTT_Setup_Table.[UserID]
PIVOT GANTT_Setup_Table.[TimeInTask] IN("6am","6:30am","7am",,"7:30am","8am","8:30am","9am","9:30am","10am","10:30am","11am","11:30am","12pm","12:30pm","1pm","1:30pm","2pm","2:30pm","3pm","3:30pm","4pm","4:30pm","5pm","5:30pm","6pm","6:30pm","7pm","7:30pm","8pm","8:30pm","9pm","9:30pm","10pm","10:30pm","11pm","11:30pm","12am","12:30am","1am","1:30am","2am","2:30am","3am","3:30am","4am","4:30am","5am","5:30am");
我假设VBA看起来像这样...
private sub commandbutton_click()
dim db as Datebase
dim DelOld as string
set db = currentdb
DelOld = "DELETE * FROM GANTT_Setup_Table"
db.execute DelOld
这是我不知道如何进行的地方...我知道下一步是从任务表中获取信息,然后将其插入GANTT_Setup_Table中,但是如何确保开始和结束之间的时间任务中的时间是否插入了TaskTypeID值?
表结构示例: Task_Table
TaskID(PKey)|用户名|开始时间|结束时间| TaskTypeID | TaskDate
1 | User1 | 6:00 | 14:00 | 1 | 05-Nov-2018
2 | User1 | 14:00 | 15:00 | 2 | 05-Nov-2018
3 | User2 | 7:00 | 9:00 | 2 | 05-Nov-2018
4 | User2 | 9:00 | 11:00 | 1 | 05-Nov-2018
5 | User2 | 11:00 | 14:00 | 3 | 05-Nov-2018
我是初学者,所以请放轻松。谢谢