PatientsFirst
New member
- Local time
- Today, 06:14
- Joined
- Apr 13, 2012
- Messages
- 5
Hi! I'm hoping that you can assist me with this problem.
I've developed two tables: CredEvents and CredEventsSites that have a one to many relationship linked on the field CredEventID. CredEvents has a field that tracks the type of event entered in a field called CredEventType. I've made forms for my users that view a list of CredEvents that have happened or are scheduled to happen in the future. A click on a button gives them details of the event - including what sites (hospitals) are a part of this event.
When a user wishes to add a new Credential Event, they click a button, a form opens where they select a Credential type, target date and the involved sites. Once they've made their selections another button is clicked that runs two queries:
One query appends the new event to the CredEvents table, the second query I hoped would just append the new site records to CredEventsSites. What is happening instead is as follows:
I'm unable to load my DB - most of it is connected to a SQL backend and contains confidential information. However, I can share the SQL of the two queries that are my current headaches:
Append to CredEvents (seems to work fine)
INSERT INTO CredEvents ( Med_Prof_Record_No, CredEventType, CredDate, [Order], [Report Heading], LastUpdated, LastUpdatedBy )
SELECT Med_Prof.Med_Prof_Record_No, CredEventType.CredEventType, Month([Forms].[CredEventsAddRecord].[TargetDate]) & "/15/" & Year([Forms].[CredEventsAddRecord].[TargetDate]) AS CredDate, CredEventType.Order, CredEventType.[Report Heading], Now() AS Expr2, User_Facility_Restrictions.UserAccessID AS Expr3
FROM User_Facility_Restrictions, Med_Prof, CredEventType
WHERE (((Med_Prof.Med_Prof_Record_No)=[Forms]![CredEventsAddRecord]![Med_Prof_Record_No]) AND ((CredEventType.CredEventType)=[Forms]![CredEventsAddRecord]![Combo2]) AND ((User_Facility_Restrictions.UserAccessID)=CurrentUser()));
Append to CredEventsSites (my nemisis)
INSERT INTO CredEventsSites ( CredEventsID, [Primary], FacCode, Department_name, [Section], LastUpdated, LastUpdatedBy )
SELECT DISTINCT CredEvents.CredEventsID, CredEventSiteHold.Primary, CredEventSiteHold.FacCode, CredEventSiteHold.Department, CredEventSiteHold.Section, Date() AS Expr1, User_Facility_Restrictions.UserAccessID AS Expr3
FROM User_Facility_Restrictions, CredEventSiteHold, CredEvents INNER JOIN Med_Prof_Facilities ON CredEvents.Med_Prof_Record_No = Med_Prof_Facilities.Med_Prof_Record_No
WHERE (((User_Facility_Restrictions.UserAccessID)=CurrentUser()) AND ((CredEvents.CredEventType)=[Forms]![CredEventsAddRecord]![Combo2]) AND ((Med_Prof_Facilities.Med_Prof_Record_No)=[Forms]![CredEventsAddRecord]![Med_Prof_Record_no]) AND ((CredEvents.LastUpdated)>Second([Forms]![CredEventsAddRecord]![AddTime])-90));
I'm looking forward to hearing your ideas!
Thank you!
I've developed two tables: CredEvents and CredEventsSites that have a one to many relationship linked on the field CredEventID. CredEvents has a field that tracks the type of event entered in a field called CredEventType. I've made forms for my users that view a list of CredEvents that have happened or are scheduled to happen in the future. A click on a button gives them details of the event - including what sites (hospitals) are a part of this event.
When a user wishes to add a new Credential Event, they click a button, a form opens where they select a Credential type, target date and the involved sites. Once they've made their selections another button is clicked that runs two queries:
One query appends the new event to the CredEvents table, the second query I hoped would just append the new site records to CredEventsSites. What is happening instead is as follows:
- The new Credential Event is added to CredEvents
- The site records are added to every event for the selected physician with the same CredEventType - creating multiple site records for some Credential Events
I'm unable to load my DB - most of it is connected to a SQL backend and contains confidential information. However, I can share the SQL of the two queries that are my current headaches:
Append to CredEvents (seems to work fine)
INSERT INTO CredEvents ( Med_Prof_Record_No, CredEventType, CredDate, [Order], [Report Heading], LastUpdated, LastUpdatedBy )
SELECT Med_Prof.Med_Prof_Record_No, CredEventType.CredEventType, Month([Forms].[CredEventsAddRecord].[TargetDate]) & "/15/" & Year([Forms].[CredEventsAddRecord].[TargetDate]) AS CredDate, CredEventType.Order, CredEventType.[Report Heading], Now() AS Expr2, User_Facility_Restrictions.UserAccessID AS Expr3
FROM User_Facility_Restrictions, Med_Prof, CredEventType
WHERE (((Med_Prof.Med_Prof_Record_No)=[Forms]![CredEventsAddRecord]![Med_Prof_Record_No]) AND ((CredEventType.CredEventType)=[Forms]![CredEventsAddRecord]![Combo2]) AND ((User_Facility_Restrictions.UserAccessID)=CurrentUser()));
Append to CredEventsSites (my nemisis)
INSERT INTO CredEventsSites ( CredEventsID, [Primary], FacCode, Department_name, [Section], LastUpdated, LastUpdatedBy )
SELECT DISTINCT CredEvents.CredEventsID, CredEventSiteHold.Primary, CredEventSiteHold.FacCode, CredEventSiteHold.Department, CredEventSiteHold.Section, Date() AS Expr1, User_Facility_Restrictions.UserAccessID AS Expr3
FROM User_Facility_Restrictions, CredEventSiteHold, CredEvents INNER JOIN Med_Prof_Facilities ON CredEvents.Med_Prof_Record_No = Med_Prof_Facilities.Med_Prof_Record_No
WHERE (((User_Facility_Restrictions.UserAccessID)=CurrentUser()) AND ((CredEvents.CredEventType)=[Forms]![CredEventsAddRecord]![Combo2]) AND ((Med_Prof_Facilities.Med_Prof_Record_No)=[Forms]![CredEventsAddRecord]![Med_Prof_Record_no]) AND ((CredEvents.LastUpdated)>Second([Forms]![CredEventsAddRecord]![AddTime])-90));
I'm looking forward to hearing your ideas!
Thank you!