hmmm..
i also dunno where to start, i posted the whole code
=============================================================
Private Sub Station_CA_AfterUpdate()
On Error GoTo Err_Station_CA_AfterUpdate
'assign a variable where value = [CompleteDate]
Dim strCompleteDate As String
strCompleteDate = [Forms]![form_PlanningCA]![CompleteDate]
'**MsgBox strCompleteDate
'assign a variable where value = [CompleteDate]
Dim strStationName As String
strStationName = [Forms]![form_PlanningCA]![Station-CA]
'**MsgBox strStationName
'assign a variable where value = selected station
Dim strStationScheduleTable As String
strStationScheduleTable = "[tbl_StationSchedule-" & strStationName & "]"
'**MsgBox strStationScheduleTable
'checks selected StationName for schedule existence of [StartDate] & [EndDate]
= [CompleteDate]
'If DCount("[StartDate]", "" & strStationScheduleTable & "", "[StartDate]=
[Forms]![form_PlanningCA]![CompleteDate]") + DCount("[EndDate]", "" &
strStationScheduleTable & "", "[EndDate]=[Forms]![form_PlanningCA]!
[CompleteDate]") = 0 Then
If DCount("[StartDate]", "" & strStationScheduleTable & "", "[StartDate]=#" &
strCompleteDate & "#") + DCount("[EndDate]", "" & strStationScheduleTable &
"", "[EndDate]=#" & strCompleteDate & "#") = 0 Then
MsgBox "[" & [Forms]![form_PlanningCA]![Station-CA] & "]--> NO schedules
for " & [Forms]![form_PlanningCA]![CompleteDate] & vbCrLf & vbCrLf & "Please
select CompleteDate accordingly..!"
'clears [Station-CA]
[Forms]![form_PlanningCA]![Station-CA] = ""
'setfocus to [CompleteDate]
[Forms]![form_PlanningCA]![CompleteDate].SetFocus
Exit Sub
End If
'delete all records in [tbl_StationSchedule-View]
CurrentDb.Execute "DELETE * FROM [tbl_StationSchedule-View]", dbFailOnError
'assign a variable where value = SQL statement to append records into
[tbl_StationSchedule-View]
Dim strUpdateStationScheduleTable As String
strUpdateStationScheduleTable = "INSERT INTO [tbl_StationSchedule-View]
(LotNo, ModelName, StartDate, StartTime, EndDate, EndTime, Station) " & _
"SELECT " & strStationScheduleTable & ".LotNo,
" & strStationScheduleTable & ".ModelName, " & strStationScheduleTable & ".
StartDate, " & strStationScheduleTable & ".StartTime, " &
strStationScheduleTable & ".EndDate, " & strStationScheduleTable & ".EndTime,
""" & strStationName & """ AS Station " & _
"FROM " & strStationScheduleTable & " " & _
"WHERE (((" & strStationScheduleTable & ".
StartDate)= #" & strCompleteDate & "#)) OR (((" & strStationScheduleTable & ".
EndDate)= #" & strCompleteDate & "#)) " & _
"ORDER BY " & strStationScheduleTable & ".
StartDate, " & strStationScheduleTable & ".StartTime"
'**MsgBox strUpdateStationScheduleTable
'"WHERE (((" & strStationScheduleTable & ".
StartDate)= "#" & strCompleteDate & "#")) OR (((" & strStationScheduleTable &
".EndDate)= "#" & strCompleteDate & "#")) "
'Update records in [tbl_StationSchedule-View]
DoCmd.SetWarnings False
DoCmd.RunSQL strUpdateStationScheduleTable
DoCmd.SetWarnings True
'clears [Station-CA]
[Forms]![form_PlanningCA]![Station-CA] = ""
'Open [report_StationSchedule-View]
DoCmd.OpenReport "report_StationSchedule-View", acViewPreview
Exit_Station_CA_AfterUpdate:
Exit Sub
Err_Station_CA_AfterUpdate:
MsgBox Err.Description
Resume Exit_Station_CA_AfterUpdate
End Sub
=============================================================