
Originally Posted by
June7
I don't understand the issue. What is the problem you are having? It is not necessary to open and close a SELECT query to 'refresh'. The query does that continually even if never opened. It is RecordSource of an open form that would need to be refreshed/requeried to reflect the table edits.
What is the SQL for query "work designation table query template"?
SQL
Code:
SELECT [Work Designation Table].[Project ID], [Work Designation Table].[Project Name], [Work Designation Table].[Work Designation], [Work Designation Table].[Type Of Work], [Work Designation Table].[Start Increment], [Work Designation Table].[End Increment], [Work Designation Table].[Start Date], [Work Designation Table].[End Date]FROM [Work Designation Table]
WHERE ((([Work Designation Table].[Project ID])=[Forms]![Progress Report Form]![Project_ID]) AND (([Work Designation Table].[Project Name])=[Forms]![Progress Report Form]![Project_Name]) AND (([Work Designation Table].[Work Designation])=[Forms]![Progress Report Form]![Work_Designation]) AND (([Work Designation Table].[Type Of Work])=[Forms]![Progress Report Form]![Work_Type]));
Hmmm... I have been trying to use the link you have provided to work out something. So far I am able to finish the updating record part. But when I am trying to finish the insert record part, I kept having syntax or run time error.
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)' refresh query
DoCmd.Close acQuery, ("WD_temp")
DoCmd.OpenQuery ("WD_temp")
' counting record
Dim RecordCount As Long
RecordCount = Nz(DCount("*", "WD_temp"), 0)
If RecordCount = 1 Then 'only one record exist which is the way it is supposed to be
' copy start increment when null
Dim CopyStartIncrement As String
CopyStartIncrement = "Update wd_temp Set [start increment] = [Forms]![Progress Report Form]![start_Depth] where [start increment] is null "
DoCmd.RunSQL CopyStartIncrement
' copy start date when null
Dim CopyStartDate As String
CopyStartDate = "Update wd_temp Set [start date] = [Forms]![Progress Report Form]![date_of_work] where [start date] is null "
DoCmd.RunSQL CopyStartDate
End If
If RecordCount = 0 Then 'if initally record is not entered just in case
Dim NoRecordStart As String
NoRecordStart = "Insert into wd_temp ([Project id],[project name],[work designation],[type of work],[start increment],[start date]) values('[Forms]![Progress Report Form]![Project_ID]','[Forms]![Progress Report Form]![project_name]','[Forms]![Progress Report Form]![Work_Designation]','[Forms]![Progress Report Form]![Work_Type]','[Forms]![Progress Report Form]![Start_Depth]','[Forms]![Progress Report Form]![Date_Of_Work]')"
DoCmd.RunSQL NoRecordStart
End If
If Me.Completed = True Then 'checkbox on form is ticked
' copy end increment
Dim CopyEndIncrement As String
CopyEndIncrement = "Update wd_temp Set [end increment] = [Forms]![Progress Report Form]![End_Depth]"
DoCmd.RunSQL CopyEndIncrement
' copy end date
Dim CopyEndDate As String
CopyEndDate = "Update wd_temp Set [end date] = [Forms]![Progress Report Form]![Date_Of_Work]"
DoCmd.RunSQL CopyEndDate
End If
End Sub
The code is very messy and I might tidy it up later. I am very new to this, thanks for bearing with me 
Btw, how will you write the code for refreshing the RecordSource?