DB Structure
Table: tbl_dateLog
Field: ID (Autonumber)
Field: dateEntry(Date Format)
Table: tbl_technician
Field: ID (Auto number format)
Field: fname (string format)
Field: lname (string format)
Table: tbl_entries
Field: ID (Auto number format)
Field: dateID (number format)
Field: techID (number format)
Field: totalClaims (number format)
I have been searching for a solution for quite a while. I believe the answer is simple, but it keeps eluding me.
I would like to add a new record for Today's date using Date() in tbl_dateLog. Then loop an INSERT INTO
query that will add a new record in tbl_entries
for each tbl_technicians.ID
, place a zero for the tbl_entries.totalClaims
field, and place the tbl_dateLog.ID
in the tbl_entries.dateID
field.
I hoped something like this would get me on the right track, but I'm sure I will need a type of JOINS to add the dateID:
INSERT INTO tbl_entries (techID,totalClaims) select ID, 0 FROM tbl_technician
I am having a lot of trouble tying this all together and searching for an answer has confused me even more. I am using Access 2016.
I would like to add a new record for Today's date using Date() in tbl_dateLog.
INSERT INTO tbl_dateLog
(
dateEntry
)
SELECT
Date()
;
Then loop an INSERT INTO query that will add a new record in tbl_entries for each tbl_technicians.ID, place a zero for the tbl_entries.totalClaims field, and place the tbl_dateLog.ID in the tbl_entries.dateID field.
INSERT INTO tbl_entries
(
dateID,
techID,
totalClaims
)
SELECT
(SELECT [tbl_dateLog]![ID] FROM [tbl_dateLog] where [tbl_dateLog]![dateEntry] = DATE()),
tbl_technician.ID,
0
FROM
tbl_technician
;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.