Public Sub AppendSPOT(strUserId As String, dteActivityDate As Date)
Dim strDelete As String, strAppendSPOT As String, strUserId As String
Dim strNoSpotData As String, qdfNoSpotData As QueryDef
Set db = CurrentDb
'Selects data from the production database to see if any spot data
'already exists. If it has all been deleted, either by user or system,
'then there should be no data in the EmpStats table either. The row count
'returned for this query satisfies this criteria of rows existing or not
strNoSpotData = "SELECT tblProductionData.UserID, tblProductionData.SystemUserID, " & _
"tblProductionData.ActivityDate, tblProductionData.WFLWID, tblWorkFlows.DSRID " & _
"FROM tblProductionData INNER JOIN tblWorkFlows ON " & _
"tblProductionData.WFLWID = tblWorkFlows.WFLWID " & _
"WHERE tblProductionData.UserID = '" & strUserId & "' AND " & _
"tblProductionData.ActivityDate = #" & dteActivityDate & "# AND " & _
"tblWorkFlows.DSRID = 'DSR3' "
Set qdfNoSpotData = db.CreateQueryDef("qryNoSpotData & strUser & ", strNoSpotData)
Set rs = CurrentDb.OpenRecordset("qryNoSpotData & strUser & ")
If rs.RecordCount > 0 Then
DoCmd.RunSQL strDelete 'For this example, deleted
DoCmd.RunSQL strAppendSPOT 'For this example, deleted
Else
DoCmd.RunSQL strDelete 'For this example, deleted
End If
DoCmd.DeleteObject acQuery, ("qryNoSpotData & strUser & ")
Set rs = Nothing
Set qdfNoSpotData = Nothing
Set db = Nothing
End Sub
ASKER
ASKER
Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.
TRUSTED BY