M
marianne
I need to be able to update a table using a form. I have been trying without
success to write code to run an append query with a loop. What is happening
is that the loop doesn't end and access stops responding.Obviously I have it
well and truly wrong. Could someone please help me. The code is as follows:
Private Sub repeat_Click()
Do Until Me.ServDate >= DLookup("[End Date]", "[tblContracts]", "[Service
No]=Forms![frmService_Date_and_Times]![Service_Plan_ID]")
DoCmd.OpenQuery ("qryServDate")
If Me.ServDate >= DLookup("[End Date]", "[tblContracts]", "[Service
No]=Forms![frmService_Date_and_Times]![Service_Plan_ID]") Then Exit Do
Loop
End Sub
The query is as follows:
INSERT INTO tblService_Date_and_Times ( Service_Plan_ID, ServDate,
Start_Time, End_Time, Carer, Frequency, ConSt_Date, ConEnd_Date )
SELECT tblService_Date_and_Times.Service_Plan_ID,
DateAdd("d",tblFrequency!Calculation,tblService_Date_and_Times!ServDate) AS
ServDate, tblService_Date_and_Times.Start_Time,
tblService_Date_and_Times.End_Time, tblService_Date_and_Times.Carer,
tblService_Date_and_Times.Frequency, tblService_Date_and_Times.ConSt_Date,
tblService_Date_and_Times.ConEnd_Date
FROM ((tblFrequency INNER JOIN tblService_Date_and_Times ON
tblFrequency.Frequency = tblService_Date_and_Times.Frequency) INNER JOIN
qryOldestRec ON tblService_Date_and_Times.recNum = qryOldestRec.MaxOfrecNum)
INNER JOIN tblContracts ON (tblFrequency.Frequency = tblContracts.Freq) AND
(tblService_Date_and_Times.Service_Plan_ID = tblContracts.[Service No])
WHERE
(((DateAdd("d",[tblFrequency]![Calculation],[tblService_Date_and_Times]![ServDate]))<=[tblContracts]![End Date]));
success to write code to run an append query with a loop. What is happening
is that the loop doesn't end and access stops responding.Obviously I have it
well and truly wrong. Could someone please help me. The code is as follows:
Private Sub repeat_Click()
Do Until Me.ServDate >= DLookup("[End Date]", "[tblContracts]", "[Service
No]=Forms![frmService_Date_and_Times]![Service_Plan_ID]")
DoCmd.OpenQuery ("qryServDate")
If Me.ServDate >= DLookup("[End Date]", "[tblContracts]", "[Service
No]=Forms![frmService_Date_and_Times]![Service_Plan_ID]") Then Exit Do
Loop
End Sub
The query is as follows:
INSERT INTO tblService_Date_and_Times ( Service_Plan_ID, ServDate,
Start_Time, End_Time, Carer, Frequency, ConSt_Date, ConEnd_Date )
SELECT tblService_Date_and_Times.Service_Plan_ID,
DateAdd("d",tblFrequency!Calculation,tblService_Date_and_Times!ServDate) AS
ServDate, tblService_Date_and_Times.Start_Time,
tblService_Date_and_Times.End_Time, tblService_Date_and_Times.Carer,
tblService_Date_and_Times.Frequency, tblService_Date_and_Times.ConSt_Date,
tblService_Date_and_Times.ConEnd_Date
FROM ((tblFrequency INNER JOIN tblService_Date_and_Times ON
tblFrequency.Frequency = tblService_Date_and_Times.Frequency) INNER JOIN
qryOldestRec ON tblService_Date_and_Times.recNum = qryOldestRec.MaxOfrecNum)
INNER JOIN tblContracts ON (tblFrequency.Frequency = tblContracts.Freq) AND
(tblService_Date_and_Times.Service_Plan_ID = tblContracts.[Service No])
WHERE
(((DateAdd("d",[tblFrequency]![Calculation],[tblService_Date_and_Times]![ServDate]))<=[tblContracts]![End Date]));