Function using DELETE on table records, problems with permission

Futurehero

New member
Local time
Tomorrow, 04:45
Joined
Jul 30, 2013
Messages
4
Greetings folks!
I have a bit of a problem with a report.
The exact specifics are as follows:
-I have a function to populate a table that will be used for a chart that illustrates the difference between the planned number of drawings for a shipyard as compared to the actual number, over a period of time.
-This period is in 1 month increments , and the dates are stored in a table. (tblGraphDate)
-There are 2 diferent tables: one for the drawings, and one for the number of revisions for each drawing, tblDwgMain and tblDwgRev
the function iterates through each element of the date table, and selects from both of the other two tables the total number of entries matching the following criteria:
-The subgroup value for both matches a value from a drop-down menu in a form
-The date for each entry (tblDwgMain.PlanIFC and tblDwgRev.[ActIFC] ) is less than the current element in the date-table,

Then, it populates a temporary table in the format of :
Date........ Planned no of Drawings...........Actual no of Drawings.

.....which is then used to as the basis for the chart
The problem is that this temporary table has all its records deleted at the start of the function, and this causes problems since users don't have permissions to delete data.
I have to redesign this function without the delete command.

I have 0 experience using vba, but some experience with SQL.


Here's the code for the function (I did not make this function, just received the explanation for it).
Any suggestions would be appreciated.
Many thanks in advance.

Private Sub CalIFCData()
Dim DBS As Database
Dim Rst1, Rst2, Rst3, Rst4 As DAO.Recordset
Dim qryStr1, qryStr2, qryStr3, qryStr4 As String
Dim FormGrp As String
Dim IFCRev As String

DoCmd.Hourglass True

Set DBS = CurrentDb

qryStr1 = "SELECT * FROM tblGraphDate ORDER BY RptMth"

DBS.Execute "DELETE * FROM tblIFC"

Set Rst1 = DBS.OpenRecordset(qryStr1)
Set Rst4 = DBS.OpenRecordset("tblIFC")
FormGrp = [Forms]![frmProgSum]![Text14]
IFCRev = DLookup("IFCRev", "tblJobInfo")

With Rst4
While Not Rst1.EOF
qryStr2 = "SELECT Count(tblDwgMain.PlanIFC) AS PIFCC " & _
"FROM tblDwgMain " & _
"WHERE" & _
"(((IIf(" & Chr(34) & FormGrp & Chr(34) & "= 'ALL',True," & _
"[tblDwgMain].[SubGrp]=" & Chr(34) & FormGrp & Chr(34) & "))<>False) " & _
"AND ((tblDwgMain.[PlanIFC])<=#" & Month(Rst1!RptMth) & "/" & Day(Rst1!RptMth) & "/" & Year(Rst1!RptMth) & "#));"
Set Rst2 = DBS.OpenRecordset(qryStr2)
.AddNew
!RptMth = Rst1!RptMth
!PIFC = Rst2!PIFCC
If Rst1!RptMth <= [Forms]![frmProgSum].[Text6] Then
qryStr3 = "SELECT Count(tblDwgRev.DwgNo) AS AIFCC " & _
"FROM (SELECT tblDwgRev.DwgNo " & _
"FROM tblDwgMain INNER JOIN tblDwgRev ON tblDwgMain.DwgNo=tblDwgRev.DwgNo " & _
"WHERE" & _
"(((IIf(" & Chr(34) & FormGrp & Chr(34) & "= 'ALL',True," & _
"[tblDwgMain].[SubGrp]=" & Chr(34) & FormGrp & Chr(34) & "))<>False) " & _
"AND ((tblDwgRev.[ActIFC])<=#" & Month(Rst1!RptMth) & "/" & Day(Rst1!RptMth) & "/" & Year(Rst1!RptMth) & "#)) " & _
"GROUP BY tblDwgRev.DwgNo);"
Set Rst3 = DBS.OpenRecordset(qryStr3)
!AIFC = Rst3!AIFCC
End If
.Update
Rst1.MoveNext
Wend
End With

DoCmd.Hourglass False
End Sub
 
...
The problem is that this temporary table has all its records deleted at the start of the function, and this causes problems since users don't have permissions to delete data.
Any suggestions would be appreciated.
Many thanks in advance.
Then give them the needed permissions, if the problem lays here!
Maybe an other solution is to drop the table and create a new one on fly, it can be done using SQL.
 
Thank you for your response. I will try using CREATE and DROP.
 

Users who are viewing this thread

Back
Top Bottom