473,396 Members | 2,108 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Moving a field into a Temp field receiving a [3027] Cannot Update. DB is read-only.

133 100+
In the following code, an error is generated when trying to move a selected record into a temp field to evaluate the record. the error is "[3027] Cannot Update. DB is read-only."

I am looking to get the selected record evaluate it. if a criteria is met, it will written to a table.

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Dim rst As DAO.Recordset
  4. Dim dbs As DAO.Database
  5. Dim strSQL As String
  6. Dim strFirstRec As String
  7. Dim strPR_ID_TEMP As String
  8. Dim strWorkflow_Step_Name_TEMP As String
  9. Dim strWorkflow_Step_Date_TEMP As String
  10.  
  11. Private Sub Generate__PR_Status_Table_Click()
  12. On Error GoTo Err_Hndlr
  13.  
  14.  
  15. strSQL = "SELECT T_PRApprovalHistory.PR_ID,  " & _
  16.                 "T_PRApprovalHistory.PR_Date,  " & _
  17.                 "T_PRApprovalHistory.Workflow_Step_Name,  " & _
  18.                 "T_PRApprovalHistory.Workflow_Step_Date,  " & _
  19.                 "Count(T_PRApprovalHistory.Workflow_Step_Date) AS CountOfWorkflow_Step_Date " & _
  20.         "FROM T_PRApprovalHistory  " & _
  21.         "GROUP BY T_PRApprovalHistory.PR_ID,  " & _
  22.                  "T_PRApprovalHistory.PR_Date,  " & _
  23.                  "T_PRApprovalHistory.Workflow_Step_Name,  " & _
  24.                  "T_PRApprovalHistory.Workflow_Step_Date " & _
  25.         "HAVING (((T_PRApprovalHistory.PR_ID)=11050254)) " & _
  26.         "ORDER BY T_PRApprovalHistory.Workflow_Step_Date"
  27.  
  28.  
  29.  
  30. Set rst = CurrentDb.OpenRecordset(strSQL)
  31.  
  32.  
  33. strFirstRec = "Yes"
  34.  
  35. Do Until rst.EOF
  36.     Debug.Print strFirstRec; " "; rst!PR_ID & " "; rst!PR_Date&; " "; rst!Workflow_Step_Name&; " "; rst!workflow_Step_Date; " "; rst!CountOfWorkflow_Step_Date
  37.     If strFirstRec = "Yes" Then
  38.         strFirstRec = "No"
  39.         rst!workflow_Step_Date = strWorkflow_Step_Date_TEMP
  40.         rst!Workflow_Step_Name = strWorkflow_Step_Name_TEMP
  41.         rst!PR_ID = strPR_ID_TEMP
  42.  
  43.     End If
  44.  
  45.     If rst!PR_ID = strPR_ID_TEMP Then
  46.         If rst!Workflow_Step_Name = strWorkflow_Step_Name_TEMP Then
  47.             If rst!workflow_Step_Date = strWorkflow_Step_Date_TEMP Then
  48.                 rst!workflow_Step_Date = strWorkflow_Step_Date_TEMP
  49.             End If
  50.         Else
  51. '            write record
  52.             rst!workflow_Step_Date = strWorkflow_Step_Date_TEMP
  53.             rst!Workflow_Step_Name = strWorkflow_Step_Name_TEMP
  54.         End If
  55.     Else
  56. '        write record
  57.         rst!workflow_Step_Date = strWorkflow_Step_Date_TEMP
  58.         rst!Workflow_Step_Name = strWorkflow_Step_Name_TEMP
  59.         rst!PR_ID = strPR_ID_TEMP
  60.     End If
  61.  
  62.     rst.MoveNext
  63. Loop
  64. Exit Sub
  65.  
  66.  
  67. Err_Hndlr:
  68.     MsgBox "[" & Err.Number & "]:  " & Err.Description, vbInformation, "Generate__PR_Status_Table_Click()"
  69. End Sub
Mar 4 '10 #1
25 2471
NeoPa
32,556 Expert Mod 16PB
This is unlikely to be related to your code at all.

You posted the error message (helpfully). Did it not occur to you that your problem was with the access to the database file itself. I suggest you look at that issue and see what you can find. We would need more information about this before we can shed light in the right direction.
Mar 4 '10 #2
patjones
931 Expert 512MB
Hi dowling -

Your query has a "GROUP BY", which makes the resulting recordset read-only.

As a side note, usually when you make a change to a recordset, you need to use the "Edit" and "Update" recordset methods. For instance:

Expand|Select|Wrap|Line Numbers
  1. rst.Edit
  2.  
  3. rst!Workflow_Step_Date = strWorkflow_Step_Date_TEMP
  4. rst!Workflow_Step_Name = strWorkflow_Step_Name_TEMP
  5.  
  6. rst.Update

Pat
Mar 4 '10 #3
dowlingm815
133 100+
Pat,

The code is reading the data and then setting a temporary field equal to read-only fields. It is not editing the fields, therefore, I am not following your direction.

Mary
Mar 5 '10 #4
dowlingm815
133 100+
NeoPa,

I am not sure what i am looking for within the db. the structure is as follows:

Expand|Select|Wrap|Line Numbers
  1.  
  2. "[ID] COUNTER CONSTRAINT ndxID PRIMARY KEY,  " & _
  3.            "[PR_ID] TEXT(25)," & _
  4.             "[External_PR] TEXT(25), " & _
  5.             "[PR_Name] TEXT(30), " & _
  6.             "[PR_Date]DATETIME, " & _
  7.             "[Buyer_username]TEXT(30), " & _
  8.             "[Buyer_First_Name]TEXT(30), " & _
  9.             "[Buyer_Last_Name]TEXT(30), " & _
  10.             "[Buyer_Email]TEXT(30), " & _
  11.             "[Department]TEXT(30), " & _
  12.              "[Workflow_Step_Name]TEXT(30), " & _
  13.              "[Workflow_Step_Date]DATETIME, " & _
  14.              "[Workflow_Step_Action]TEXT(30), " & _
  15.              "[Approver_Username]TEXT(30), " & _
  16.              "[Approver_First_Name]TEXT(30), " & _
  17.              "[Approver_Last_Name]TEXT(30), " & _
  18.              "[Approver: Email]TEXT(30), " & _
  19.              "[Approver: Department]TEXT(30)" & _
  20.  
Mar 5 '10 #5
patjones
931 Expert 512MB
dowling -

Are not rst!Workflow_Step_Date and rst!Workflow_Step_Name fields from the query in strSQL, which has a GROUP BY clause? Queries that involve GROUP BY clauses are read-only, which means that you cannot assign values to rst!Workflow_Step_Date and rst!Workflow_Step_Name as you are trying to do here:

Expand|Select|Wrap|Line Numbers
  1. rst!Workflow_Step_Date = strWorkflow_Step_Date_TEMP 
  2. rst!Workflow_Step_Name = strWorkflow_Step_Name_TEMP

To test what I'm saying, I made a simple piece code with a GROUP BY query and tried to assign something to one of the fields in the query as you are trying to do, and also received error 3207.

Perhaps what you mean to do is

Expand|Select|Wrap|Line Numbers
  1. strWorkflow_Step_Date_TEMP = rst!Workflow_Step_Date
  2. strWorkflow_Step_Name_TEMP = rst!Workflow_Step_Name

If I'm off track here, perhaps NeoPa can shed light on the issue...

Pat
Mar 5 '10 #6
dowlingm815
133 100+
If read-only is the case and then the value of each record cannot be copied into another record, true?

In SQL, a GROUP BY can created a table. Would this be the solution, create a SQL statement creating a table instead so it is readable?

Expand|Select|Wrap|Line Numbers
  1. SELECT T_PRApprovalHistory.PR_ID, T_PRApprovalHistory.PR_Date, T_PRApprovalHistory.Workflow_Step_Name, T_PRApprovalHistory.Workflow_Step_Date, Count(T_PRApprovalHistory.PR_Date) AS [CountOfPR Date] INTO T_Group_By_Test
  2. FROM T_PRApprovalHistory
  3. GROUP BY T_PRApprovalHistory.PR_ID, T_PRApprovalHistory.PR_Date, T_PRApprovalHistory.Workflow_Step_Name, T_PRApprovalHistory.Workflow_Step_Date
  4. HAVING (((T_PRApprovalHistory.PR_ID)=11050254))
  5. ORDER BY T_PRApprovalHistory.PR_ID, T_PRApprovalHistory.Workflow_Step_Date;
  6.  
  7.  
Mar 5 '10 #7
patjones
931 Expert 512MB
dowling -

Yes, you can create a temporary table and put the results of your GROUP BY query into it. Then you could do anything you want with the records in the table.

For example:

Expand|Select|Wrap|Line Numbers
  1. Dim rstTemp As Recordset
  2. Dim rst As Recordset
  3. Dim i As Long
  4.  
  5. 'Create temporary table
  6. CurrentDb.Execute("CREATE TABLE tblTemp(PR_Id SMALLINT, Workflow_Step_Date DATETIME, Workflow_Step_Name VARCHAR(50))")
  7.  
  8. 'Bind rstTemp to the temporary table
  9. Set rstTemp = CurrentDb.OpenRecordset("tblTemp")
  10.  
  11. 'Grab the data and put it in rst
  12. Set rst = CurrentDb.OpenRecordset("SELECT T_PRApprovalHistory.PR_ID,  " & _
  13.                 "T_PRApprovalHistory.PR_Date,  " & _
  14.                 "T_PRApprovalHistory.Workflow_Step_Name,  " & _
  15.                 "T_PRApprovalHistory.Workflow_Step_Date,  " & _
  16.                 "Count(T_PRApprovalHistory.Workflow_Step_Date) AS CountOfWorkflow_Step_Date " & _
  17.         "FROM T_PRApprovalHistory  " & _
  18.         "GROUP BY T_PRApprovalHistory.PR_ID,  " & _
  19.                  "T_PRApprovalHistory.PR_Date,  " & _
  20.                  "T_PRApprovalHistory.Workflow_Step_Name,  " & _
  21.                  "T_PRApprovalHistory.Workflow_Step_Date " & _
  22.         "HAVING (((T_PRApprovalHistory.PR_ID)=11050254)) " & _
  23.         "ORDER BY T_PRApprovalHistory.Workflow_Step_Date")
  24.  
  25. 'Move the data into the temporary table
  26. rst.MoveFirst
  27. Do While rst.EOF = False
  28.  
  29.     rstTemp.AddNew
  30.  
  31.     For i = 0 To rst.Fields.Count - 1
  32.         rstTemp.Fields(i).value = rst.Fields(i).value  
  33.     Next
  34.  
  35.     rstTemp.Update
  36.     rst.MoveNext
  37.  
  38. Loop

At this point, rstTemp (and thus tblMain) should have the results of the GROUP BY query in it.

In this code, the line in bold print is what actually assigns the field value from the original query results into the temporary table. In the CREATE TABLE statement, you can add or take away fields as you see fit (I just put three of your fields in for illustration. You might also need to adjust the field types according to your needs.

Pat
Mar 5 '10 #8
NeoPa
32,556 Expert Mod 16PB
@dowlingm815
If your error message is accurate, then the contents of the database (neither code nor data) are not where you need to be looking. I would be looking at the access (small-'a') you have to your database file. Maybe it's on a share you don't have full rights to. Maybe it's simply got the Read-Only attribute set. Have you tried renaming that file? That usually indicates whether you have enough right to do any work in it at all. If you can't rename the file, you won't get very far inside it (unless it's simply in use at the time). If this is your issue we'd need more details to help you progress.
Mar 5 '10 #9
patjones
931 Expert 512MB
If your error message is accurate, then the contents of the database (neither code nor data) are not where you need to be looking.
I think that could be one cause for this error. But I was able to build a simple table and form, and regenerate this same error by attempting to update a recordset bound to a GROUP BY query, just like dowling is trying to do. When I modified the SQL to not include any aggregates I was able to do the update fine.

I could very well be wrong, but I would be interested to know whether the solution I laid out above will work for what dowling wants to do...

Pat
Mar 6 '10 #10
NeoPa
32,556 Expert Mod 16PB
@zepphead80
That applies to all of us Pat.

If you experience that message when the file is clearly fully accessible, then don't let me stop you pursuing that approach. Personally I'd check the access to the file first, that being pretty quickly and easily done after all, but I expect that your understanding may well reap dividends if that's not the problem.
Mar 7 '10 #11
dowlingm815
133 100+
the database is on my c: drive, there are no accessibility issues.
Mar 8 '10 #12
dowlingm815
133 100+
can you kindly post your code from when it works to when it doesn' t work. when i elminate the count function, i receive a 3219 invalid operaton error.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Option Compare Database
  3.  
  4. Dim rst As DAO.Recordset
  5. Dim dbs As DAO.Database
  6. Dim strSQL As String
  7. Dim strFirstRec As String
  8. Dim strPR_ID_TEMP As String
  9. Dim strWorkflow_Step_Name_TEMP As String
  10. Dim strWorkflow_Step_Date_TEMP As String
  11.  
  12. Private Sub Generate__PR_Status_Table_Click()
  13. On Error GoTo Err_Hndlr
  14.  
  15.     MsgBox "Entered the application", vbInformation
  16.  
  17.  
  18. strSQL = "SELECT T_PRApprovalHistory.PR_ID, T_PRApprovalHistory.PR_Date, T_PRApprovalHistory.Workflow_Step_Name, T_PRApprovalHistory.Workflow_Step_Date INTO T_Group_By_Test " & _
  19. "FROM T_PRApprovalHistory GROUP BY T_PRApprovalHistory.PR_ID, T_PRApprovalHistory.PR_Date, T_PRApprovalHistory.Workflow_Step_Name, T_PRApprovalHistory.Workflow_Step_Date HAVING (((T_PRApprovalHistory.PR_ID) = 11050254)) ORDER BY T_PRApprovalHistory.PR_ID, T_PRApprovalHistory.Workflow_Step_Date;"
  20.  
  21. Set rst = CurrentDb.OpenRecordset(strSQL)
  22.  
  23. Err_Hndlr:
  24.     MsgBox "[" & Err.Number & "]:  " & Err.Description, vbInformation, "Generate__PR_Status_Table_Click()"
  25. End Sub
  26.  
Mar 8 '10 #13
patjones
931 Expert 512MB
Simply removing the COUNT function isn't what I suggested. Please read my post #8 and try to implement what I'm doing there.

Just taking out the COUNT function won't work, because the query still contains a GROUP BY clause. If you really need to use the results of this query, write them to a table and then work with the table as I'm suggesting in post #8...

Pat
Mar 8 '10 #14
patjones
931 Expert 512MB
Suppose I have some code, which prints out a list for a particular employee, with: ID, last name, first name, date worked, hours worked. Then I change the hours worked each day and reprint the results. This works...

Expand|Select|Wrap|Line Numbers
  1. Dim strSQL As String
  2. Dim rst As Recordset
  3.  
  4. strSQL = "SELECT tblMain.fldERN, tblNames.fldNameLast, tblNames.fldNameFirst, tblMain.fldDate, tblMain.fldHours 
  5.           FROM tblMain INNER JOIN tblNames ON tblMain.fldERN = tblNames.fldERN 
  6.           WHERE tblMain.fldERN = '" & Replace(Replace(Me.txtERN,"'",""),"""","") & "'"
  7.  
  8. Set rst = CurrentDb.OpenRecordset(strSQL)
  9.  
  10. With rst
  11.  
  12.     'Print old records
  13.     .MoveFirst
  14.  
  15.     While Not .EOF
  16.         Debug.Print !fldERN & "   " & !fldNameLast & "   " & !fldNameFirst & "   " & Format(!fldDate, "mm/dd/yy") & "   " & !fldHours
  17.         .MoveNext
  18.     Wend
  19.  
  20.     'Modify the records
  21.     .MoveFirst
  22.  
  23.     While Not .EOF
  24.         .Edit
  25.         !fldHours = Me.txtHoursNew
  26.         .Update
  27.         .MoveNext
  28.     Wend
  29.  
  30.     'Print modified records
  31.     .MoveFirst
  32.  
  33.     While Not .EOF
  34.         Debug.Print !fldERN & "   " & !fldNameLast & "   " & !fldNameFirst & "   " & Format(!fldDate, "mm/dd/yy") & "   " & !fldHours
  35.         .MoveNext
  36.     Wend
  37.  
  38. End With

Now, suppose I change the SQL string to

Expand|Select|Wrap|Line Numbers
  1. strSQL = "SELECT tblMain.fldERN, tblNames.fldNameLast, tblNames.fldNameFirst, tblMain.fldDate, SUM(tblMain.fldHours) AS [Hours Count] 
  2.           FROM tblMain INNER JOIN tblNames ON tblMain.fldERN = tblNames.fldERN 
  3.           WHERE tblMain.fldERN = '" & Replace(Replace(Me.txtERN, "'", ""), """", "") & "' 
  4.           GROUP BY tblMain.fldERN, tblNames.fldNameLast, tblNames.fldNameFirst, tblMain.fldDate "
  5.  

which basically does the same thing, except it would, for instance, combine multiple records with the same date. I'll be able to print the records just as before:

Expand|Select|Wrap|Line Numbers
  1. With rst
  2.  
  3.     'Print old records
  4.     .MoveFirst
  5.  
  6.     While Not .EOF
  7.         Debug.Print !fldERN & "   " & !fldNameLast & "   " & !fldNameFirst & "   " & Format(!fldDate, "mm/dd/yy") & "   " & ![Hours Count]
  8.         .MoveNext
  9.     Wend
  10.  

But when I go and try to modify something from within the query (it doesn't matter what field you pick):

Expand|Select|Wrap|Line Numbers
  1.     'Modify the records
  2.     .MoveFirst
  3.  
  4.     While Not .EOF
  5.         .Edit
  6.         ![Hours Count] = Me.txtHoursNew
  7.         .Update
  8.         .MoveNext
  9.     Wend
  10.  

I get error 3027, just as you do. This is because the individual rows that result from doing a GROUP BY are combinations of multiple rows from the source table(s). In my instance, I can't go and modify total hours worked ([Hours Count]), because that result is the total from multiple rows in my source table.

If however I took my recordset here and dumped it into another table that I just created for that purpose, I'd be able to work with those records however I wanted to.

Does this make any sense?

Pat
Mar 8 '10 #15
dowlingm815
133 100+
pat,

thanks for all your help. the temporary file is the answer so far. however, i have yet to test it against moving data into a field. currently, i am recievind an [0] error code and i can't seem to find out how to elimate it. i know it means eof. the code builds the table, however, i am still receiving that error.

mary

the code is as follows:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Dim rst As DAO.Recordset
  4. Dim rstTemp As Recordset
  5. Dim i As Long
  6. Dim dbs As DAO.Database
  7. Dim strSQL As String
  8. Dim strFirstRec As String
  9. Dim strPR_ID_TEMP As String
  10. Dim strWorkflow_Step_Name_TEMP As String
  11. Dim strWorkflow_Step_Date_TEMP As String
  12.  
  13. Private Sub Generate__PR_Status_Table_Click()
  14. On Error GoTo Err_Hndlr
  15.  
  16.  
  17. 'Delete temporary table
  18. DoCmd.RunSQL "DROP TABLE tblTemp;"
  19.  
  20. 'Create temporary table
  21. CurrentDb.Execute ("CREATE TABLE tblTemp(PR_Id integer, PR_Date DATETIME, Workflow_Step_Name VARCHAR(50), Workflow_Step_Date DATETIME, CountOfWorkflow_Step_Date smallint)")
  22.  
  23. 'Bind rstTemp to the temporary table
  24. Set rstTemp = CurrentDb.OpenRecordset("tblTemp")
  25.  
  26.  
  27. 'Grab the data and put it in rst
  28. Set rst = CurrentDb.OpenRecordset("SELECT T_PRApprovalHistory.PR_ID,  " & _
  29.                 "T_PRApprovalHistory.PR_Date,  " & _
  30.                 "T_PRApprovalHistory.Workflow_Step_Name,  " & _
  31.                 "T_PRApprovalHistory.Workflow_Step_Date,  " & _
  32.                 "Count(T_PRApprovalHistory.Workflow_Step_Date) AS CountOfWorkflow_Step_Date " & _
  33.         "FROM T_PRApprovalHistory  " & _
  34.         "GROUP BY T_PRApprovalHistory.PR_ID,  " & _
  35.                  "T_PRApprovalHistory.PR_Date,  " & _
  36.                  "T_PRApprovalHistory.Workflow_Step_Name,  " & _
  37.                  "T_PRApprovalHistory.Workflow_Step_Date " & _
  38.         "HAVING (((T_PRApprovalHistory.PR_ID)=11050254)) " & _
  39.         "ORDER BY T_PRApprovalHistory.Workflow_Step_Date")
  40.  
  41.  
  42. 'Move the data into the temporary table
  43. rst.MoveFirst
  44. Do While rst.EOF = False
  45. '    Debug.Print rst!PR_ID&; " "; rst!PR_Date&; " "; rst!Workflow_Step_Name&; " "; rst!workflow_Step_Date
  46.     rstTemp.AddNew
  47.  
  48.     For i = 0 To rst.Fields.Count - 1
  49.         rstTemp.Fields(i).Value = rst.Fields(i).Value
  50. '        Debug.Print rst.Fields(i).Value
  51.     Next
  52.  
  53.     rstTemp.Update
  54.     rst.MoveNext
  55.  
  56. Loop
  57.  
  58. rst.Close
  59.  
  60.  
  61.  
  62. Err_Hndlr:
  63.     MsgBox "[" & Err.Number & "]:  " & Err.Description, vbInformation, "Generate__PR_Status_Table_Click()"
  64. End Sub
  65.  
  66.  
Mar 8 '10 #16
dowlingm815
133 100+
Besides the [0] error, with part of the logic added, the reason why i originally posted, moving the field, a new error is generated, [3020] update or cancel without AddNew or Edit. what i don't understand, the field that is being updated is a holding area not a record. the code is as follows:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Dim rst As DAO.Recordset
  4. Dim rstTemp As Recordset
  5. Dim i As Long
  6. Dim dbs As DAO.Database
  7. Dim strSQL As String
  8. Dim strFirstRec As String
  9. Dim strPR_ID_TEMP As String
  10. Dim strWorkflow_Step_Name_TEMP As String
  11. Dim strWorkflow_Step_Date_TEMP As Date
  12.  
  13. Private Sub Generate__PR_Status_Table_Click()
  14. On Error GoTo Err_Hndlr
  15.  
  16.  
  17. 'Delete temporary table
  18. DoCmd.RunSQL "DROP TABLE tblTemp;"
  19.  
  20. 'Create temporary table
  21. CurrentDb.Execute ("CREATE TABLE tblTemp(PR_Id integer, PR_Date DATETIME, Workflow_Step_Name VARCHAR(50), Workflow_Step_Date DATETIME, CountOfWorkflow_Step_Date smallint)")
  22.  
  23. 'Bind rstTemp to the temporary table
  24. Set rstTemp = CurrentDb.OpenRecordset("tblTemp")
  25.  
  26.  
  27. 'Grab the data and put it in rst
  28. Set rst = CurrentDb.OpenRecordset("SELECT T_PRApprovalHistory.PR_ID,  " & _
  29.                 "T_PRApprovalHistory.PR_Date,  " & _
  30.                 "T_PRApprovalHistory.Workflow_Step_Name,  " & _
  31.                 "T_PRApprovalHistory.Workflow_Step_Date,  " & _
  32.                 "Count(T_PRApprovalHistory.Workflow_Step_Date) AS CountOfWorkflow_Step_Date " & _
  33.         "FROM T_PRApprovalHistory  " & _
  34.         "GROUP BY T_PRApprovalHistory.PR_ID,  " & _
  35.                  "T_PRApprovalHistory.PR_Date,  " & _
  36.                  "T_PRApprovalHistory.Workflow_Step_Name,  " & _
  37.                  "T_PRApprovalHistory.Workflow_Step_Date " & _
  38.         "HAVING (((T_PRApprovalHistory.PR_ID)=11050254)) " & _
  39.         "ORDER BY T_PRApprovalHistory.Workflow_Step_Date")
  40.  
  41.  
  42. 'Move the data into the temporary table
  43. rst.MoveFirst
  44. Do While rst.EOF = False
  45. '    Debug.Print rst!PR_ID&; " "; rst!PR_Date&; " "; rst!Workflow_Step_Name&; " "; rst!workflow_Step_Date
  46.     rstTemp.AddNew
  47.  
  48.     For i = 0 To rst.Fields.Count - 1
  49.         rstTemp.Fields(i).Value = rst.Fields(i).Value
  50. '        Debug.Print rst.Fields(i).Value
  51.     Next
  52.  
  53.     rstTemp.Update
  54.     rst.MoveNext
  55.  
  56. Loop
  57.  
  58. rst.Close
  59.  
  60. '********************************************************logic*****************************************
  61.  
  62. strFirstRec = "Yes"
  63. rstTemp.MoveFirst
  64.  
  65. Do While rstTemp.EOF = False
  66.     Debug.Print rstTemp!PR_ID&; " "; rstTemp!PR_Date&; " "; rstTemp!Workflow_Step_Name&; " "; rstTemp!workflow_Step_Date
  67.     If strFirstRec = "Yes" Then
  68.         strFirstRec = "No"
  69.         rstTemp!workflow_Step_Date = strWorkflow_Step_Date_TEMP
  70.         rstTemp!Workflow_Step_Name = strWorkflow_Step_Name_TEMP
  71.         rstTemp!PR_ID = strPR_ID_TEMP
  72.  
  73.     End If
  74.  
  75.     If rstTemp!PR_ID = strPR_ID_TEMP Then
  76.         If rstTemp!Workflow_Step_Name = strWorkflow_Step_Name_TEMP Then
  77.             If rstTemp!workflow_Step_Date = strWorkflow_Step_Date_TEMP Then
  78.                 rstTemp!workflow_Step_Date = strWorkflow_Step_Date_TEMP
  79.             End If
  80.         Else
  81. '            write record
  82.             rstTemp!workflow_Step_Date = strWorkflow_Step_Date_TEMP
  83.             rstTemp!Workflow_Step_Name = strWorkflow_Step_Name_TEMP
  84.         End If
  85.     Else
  86. '        write record
  87.         rstTemp!workflow_Step_Date = strWorkflow_Step_Date_TEMP
  88.         rstTemp!Workflow_Step_Name = strWorkflow_Step_Name_TEMP
  89.         rstTemp!PR_ID = strPR_ID_TEMP
  90.     End If
  91.  
  92.     rstTemp.MoveNext
  93.  
  94. Loop
  95.  
  96. rstTemp.Close
  97.  
  98.  
  99. Err_Hndlr:
  100.     MsgBox "[" & Err.Number & "]:  " & Err.Description, vbInformation, "Generate__PR_Status_Table_Click()"
  101. End Sub
  102.  
Mar 8 '10 #17
patjones
931 Expert 512MB
What lines are you getting the errors on?

Pat
Mar 8 '10 #18
dowlingm815
133 100+
Expand|Select|Wrap|Line Numbers
  1. rstTemp!workflow_Step_Date = strWorkflow_Step_Date_TEMP 
  2.  
Mar 8 '10 #19
patjones
931 Expert 512MB
That's because you have not preceded that part of the code with an rstTemp.Edit:

Expand|Select|Wrap|Line Numbers
  1. rstTemp.Edit
  2.  
  3. rstTemp!workflow_Step_Date = strWorkflow_Step_Date_TEMP
  4. rstTemp!Workflow_Step_Name = strWorkflow_Step_Name_TEMP
  5. rstTemp!PR_ID = strPR_ID_TEMP
  6.  
  7. rstTemp.Update

But, my other concern here is that, up to this point in the code, you have not assigned anything to strWorkflow_Step_Date_TEMP or strWorkflow_Step_Name_TEMP or strPR_ID_TEMP ...so what is the point of those three lines of code?

Pat
Mar 8 '10 #20
dowlingm815
133 100+
pat,

the issue was i was not assigning the correct fields, it should have been reverse to the above post.

this application summarizes data by grouping and evaluate the workflow dates to ensure the last workflow date is written to a table. For instance, the input data would be:

11050254 5/18/2009 Banner Budget Auth 5/18/2009
11050254 5/18/2009 Department Approvals 5/18/2009
11050254 5/18/2009 Business Office Approvals 5/27/2009
11050254 5/18/2009 Purchasing Approvals 7/21/2009
11050254 5/18/2009 Purchasing Approvals 7/22/2009
11050254 5/18/2009 Purchasing Next FY 7/23/2009
11050254 5/18/2009 Processed FY Orders 7/24/2009
11050254 5/18/2009 Purchasing Next FY 7/24/2009

the summary table will contain the following:
11050254 5/18/2009 Banner Budget Auth 5/18/2009
11050254 5/18/2009 Department Approvals 5/18/2009
11050254 5/18/2009 Business Office Approvals 5/27/2009
11050254 5/18/2009 Purchasing Approvals 7/22/2009
11050254 5/18/2009 Processed FY Orders 7/24/2009
11050254 5/18/2009 Purchasing Next FY 7/24/2009

The code was altered as shown below which i am now getting the correct results but still receiving [0] EOF error, any suggestions?

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Dim rst As DAO.Recordset
  4. Dim rstTemp As Recordset
  5. Dim i As Long
  6. Dim dbs As DAO.Database
  7. Dim strSQL As String
  8.  
  9. Dim strFirstRec As String
  10.  
  11. '*********temp fields for writing records
  12. Dim strPR_ID_TEMP As String
  13. Dim strWorkflow_Step_Name_TEMP As String
  14. Dim strWorkflow_Step_Date_TEMP As Date
  15. Dim strPR_Date_TEMP As Date
  16. Dim strCountOfWorkflow_Step_Date As Integer
  17.  
  18.  
  19. Private Sub Generate__PR_Status_Table_Click()
  20. On Error GoTo Err_Hndlr
  21.  
  22.  
  23. 'Delete temporary table
  24. DoCmd.RunSQL "DROP TABLE tblTemp;"
  25.  
  26. 'Create temporary table
  27. CurrentDb.Execute ("CREATE TABLE tblTemp(PR_Id integer, PR_Date DATETIME, Workflow_Step_Name VARCHAR(50), Workflow_Step_Date DATETIME, CountOfWorkflow_Step_Date smallint)")
  28.  
  29. 'Bind rstTemp to the temporary table
  30. Set rstTemp = CurrentDb.OpenRecordset("tblTemp")
  31.  
  32.  
  33. 'Grab the data and put it in rst
  34. Set rst = CurrentDb.OpenRecordset("SELECT T_PRApprovalHistory.PR_ID,  " & _
  35.                 "T_PRApprovalHistory.PR_Date,  " & _
  36.                 "T_PRApprovalHistory.Workflow_Step_Name,  " & _
  37.                 "T_PRApprovalHistory.Workflow_Step_Date,  " & _
  38.                 "Count(T_PRApprovalHistory.Workflow_Step_Date) AS CountOfWorkflow_Step_Date " & _
  39.         "FROM T_PRApprovalHistory  " & _
  40.         "GROUP BY T_PRApprovalHistory.PR_ID,  " & _
  41.                  "T_PRApprovalHistory.PR_Date,  " & _
  42.                  "T_PRApprovalHistory.Workflow_Step_Name,  " & _
  43.                  "T_PRApprovalHistory.Workflow_Step_Date " & _
  44.         "HAVING (((T_PRApprovalHistory.PR_ID)=11050254)) " & _
  45.         "ORDER BY T_PRApprovalHistory.Workflow_Step_Date, T_PRApprovalHistory.Workflow_Step_Name")
  46.  
  47.  
  48. 'Move the data into the temporary table
  49. rst.MoveFirst
  50. Do While rst.EOF = False
  51.     Debug.Print rst!PR_ID&; " "; rst!PR_Date&; " "; rst!Workflow_Step_Name&; " "; rst!workflow_Step_Date
  52.     rstTemp.AddNew
  53.  
  54.     For i = 0 To rst.Fields.Count - 1
  55.         rstTemp.Fields(i).Value = rst.Fields(i).Value
  56.     Next
  57.  
  58.     rstTemp.Update
  59.     rst.MoveNext
  60.  
  61. Loop
  62.  
  63. rst.Close
  64.  
  65. '********************************************************logic*****************************************
  66.  
  67. strFirstRec = "Yes"
  68.  
  69. ' **** initialize temporary fields, date is set to dummy initial date, it has no meaning
  70. strWorkflow_Step_Date_TEMP = "03/19/2007"
  71. strWorkflow_Step_Name_TEMP = " "
  72. strPR_ID_TEMP = " "
  73. strPR_Date_TEMP = "03/19/2007"
  74. strCountOfWorkflow_Step_Date = "0"
  75.  
  76. '**** create output table
  77. 'Delete temporary table
  78. DoCmd.RunSQL "DROP TABLE tblApprovalHistorySummary;"
  79.  
  80. 'Create temporary table
  81. CurrentDb.Execute ("CREATE TABLE tblApprovalHistorySummary(PR_Id integer, PR_Date DATETIME, Workflow_Step_Name VARCHAR(50), Workflow_Step_Date DATETIME, CountOfWorkflow_Step_Date smallint)")
  82.  
  83. 'Bind rstTemp to the temporary table
  84. Set rstSummary = CurrentDb.OpenRecordset("tblApprovalHistorySummary")
  85.  
  86.  
  87. rstTemp.MoveFirst
  88.  
  89. Do While rstTemp.EOF = False
  90.  
  91.     Debug.Print "Temp file "; rstTemp!PR_ID&; " "; rstTemp!PR_Date&; " "; rstTemp!Workflow_Step_Name&; " "; rstTemp!workflow_Step_Date
  92.  
  93.     If strFirstRec = "Yes" Then
  94.         strFirstRec = "No"
  95.         strWorkflow_Step_Date_TEMP = rstTemp!workflow_Step_Date
  96.         strWorkflow_Step_Name_TEMP = rstTemp!Workflow_Step_Name
  97.         strPR_ID_TEMP = rstTemp!PR_ID
  98.         strPR_Date_TEMP = rstTemp!PR_Date
  99.         strCountOfWorkflow_Step_Date = rstTemp!CountOfWorkflow_Step_Date
  100.     End If
  101.  
  102.     If rstTemp!PR_ID = strPR_ID_TEMP Then
  103.         If rstTemp!Workflow_Step_Name = strWorkflow_Step_Name_TEMP Then
  104.             If rstTemp!workflow_Step_Date = strWorkflow_Step_Date_TEMP Then
  105.                 strWorkflow_Step_Date_TEMP = rstTemp!workflow_Step_Date
  106.             End If
  107.         Else
  108. '***        write record
  109.             rstSummary.AddNew
  110.                 rstSummary!workflow_Step_Date = strWorkflow_Step_Date_TEMP
  111.                 rstSummary!Workflow_Step_Name = strWorkflow_Step_Name_TEMP
  112.                 rstSummary!PR_ID = strPR_ID_TEMP
  113.                 rstSummary!PR_Date = strPR_Date_TEMP
  114.                 rstSummary!CountOfWorkflow_Step_Date = strCountOfWorkflow_Step_Date
  115.             rstSummary.Update
  116.  
  117.             strWorkflow_Step_Date_TEMP = rstTemp!workflow_Step_Date
  118.             strWorkflow_Step_Name_TEMP = rstTemp!Workflow_Step_Name
  119.         End If
  120.     Else
  121. '***   write record
  122.         rstSummary.AddNew
  123.             rstSummary!workflow_Step_Date = strWorkflow_Step_Date_TEMP
  124.             rstSummary!Workflow_Step_Name = strWorkflow_Step_Name_TEMP
  125.             rstSummary!PR_ID = strPR_ID_TEMP
  126.             rstSummary!PR_Date = strPR_Date_TEMP
  127.             rstSummary!CountOfWorkflow_Step_Date = strCountOfWorkflow_Step_Date
  128.         rstSummary.Update
  129.  
  130.         strWorkflow_Step_Date_TEMP = rstTemp!workflow_Step_Date
  131.         strWorkflow_Step_Name_TEMP = rstTemp!Workflow_Step_Name
  132.         strPR_ID_TEMP = rstTemp!PR_ID
  133.     End If
  134.  
  135.     rstTemp.MoveNext
  136. Loop
  137.  
  138. rstTemp.Close
  139. rstSummary.Close
  140.  
  141.  
  142. Err_Hndlr:
  143.     MsgBox "[" & Err.Number & "]:  " & Err.Description, vbInformation, "Generate__PR_Status_Table_Click()"
  144. End Sub
  145.  
  146.  
Mar 9 '10 #21
patjones
931 Expert 512MB
What line are you getting the error on?
Mar 9 '10 #22
dowlingm815
133 100+
got it...there was no exit sub. it went right to Err_Hndlr.

Case closed.

thank you
Mar 9 '10 #23
patjones
931 Expert 512MB
You're welcome!

Seeing your sample data really makes it clear what you are doing. I'd suggest posting some sample data the next time you have a problem, and what you want the result to look like, to help people understand better what you're trying to do.

In your case, while the algorithm you have appears to work, I can't help but think there might be a more straightforward method. For instance, I wonder if there is a way you can write the SQL so that it just gives you the end result you want.

If there aren't any confidentiality concerns, maybe you could make a wider range of your sample data available for me to play with?

Pat
Mar 9 '10 #24
dowlingm815
133 100+
Good morning Pat,

I had to alter to the code to accommodate the workflow order. Ultimately, the Summary table will feed a report that will detail the number of days it takes for the workflow approval process.

Here is the new table, tblWorkflowApprovalStep, that was added

[data]
Workflow_Step_Order Workflow_Step_Name
1 Auto Reject
2 Banner Budget Auth
3 Radiation Safety Approval
4 Hazardous Material Approval
5 IT Approval
6 Department Approvals
7 Catch All
8 Business Office Approvals
9 Grant Approvals
10 Plant Approvals
11 Form Approval
12 New Supplier Data Entry
13 Sole Source Approval
14 Purchasing Approvals
15 Purchasing Next FY
16 Processed FY Orders
17 Banner PR Create
18 Create PO

[/data]
here is some test data from the T_PRApprovalHistory.

[data]
PR_ID PR_Date Workflow_Step_Name Workflow_Step_Date
11050254 18-May-09 Department Approvals 18-May-09
11050254 18-May-09 Department Approvals 18-May-09
11050254 18-May-09 Department Approvals 18-May-09
11050254 18-May-09 Banner Budget Auth 18-May-09
11050390 18-May-09 Banner Budget Auth 18-May-09
11050390 18-May-09 Department Approvals 18-May-09
11050390 18-May-09 Department Approvals 18-May-09
11050254 18-May-09 Business Office Approvals 27-May-09
11050390 18-May-09 Business Office Approvals 27-May-09
11050390 18-May-09 Purchasing Approvals 03-Jun-09
11050390 18-May-09 Purchasing Next FY 25-Jun-09
11050390 18-May-09 Processed FY Orders 29-Jun-09
11050254 18-May-09 Purchasing Approvals 21-Jul-09
11050254 18-May-09 Purchasing Approvals 22-Jul-09
11050254 18-May-09 Purchasing Next FY 23-Jul-09
11050254 18-May-09 Purchasing Next FY 24-Jul-09
11050254 18-May-09 Processed FY Orders 24-Jul-09
13728252 01-Dec-09 Grant Approvals 02-Dec-09
13728252 01-Dec-09 Banner Budget Auth 02-Dec-09
13728252 01-Dec-09 Form Approval 07-Dec-09
13728252 01-Dec-09 Form Approval 07-Dec-09
13728252 01-Dec-09 Form Approval 07-Dec-09
13728252 01-Dec-09 Form Approval 07-Dec-09
13728252 01-Dec-09 Form Approval 07-Dec-09
13728252 01-Dec-09 Form Approval 07-Dec-09
13728252 01-Dec-09 Form Approval 07-Dec-09
13728252 01-Dec-09 Form Approval 07-Dec-09
13728252 01-Dec-09 Form Approval 07-Dec-09
13728252 01-Dec-09 Form Approval 07-Dec-09
13728252 01-Dec-09 Form Approval 07-Dec-09
13728252 01-Dec-09 Form Approval 07-Dec-09
13728252 01-Dec-09 Form Approval 07-Dec-09
13728252 01-Dec-09 Form Approval 07-Dec-09
13728252 01-Dec-09 Form Approval 07-Dec-09
13728252 01-Dec-09 Form Approval 07-Dec-09
13728252 01-Dec-09 Form Approval 07-Dec-09
13728252 01-Dec-09 Form Approval 07-Dec-09
13728252 01-Dec-09 Form Approval 07-Dec-09
13728252 01-Dec-09 Form Approval 07-Dec-09
13728252 01-Dec-09 Form Approval 07-Dec-09
13728252 01-Dec-09 Form Approval 07-Dec-09
13728252 01-Dec-09 Form Approval 07-Dec-09
13728252 01-Dec-09 Form Approval 07-Dec-09
13728252 01-Dec-09 Form Approval 07-Dec-09
13728252 01-Dec-09 Form Approval 07-Dec-09
13728252 01-Dec-09 Form Approval 07-Dec-09
13728252 01-Dec-09 Form Approval 07-Dec-09
13728252 01-Dec-09 Form Approval 07-Dec-09
13728252 01-Dec-09 Form Approval 07-Dec-09
13728252 01-Dec-09 Form Approval 07-Dec-09
13728252 01-Dec-09 Form Approval 07-Dec-09
14265338 14-Jan-10 Form Approval 15-Jan-10
14264637 14-Jan-10 Form Approval 05-Feb-10
14729068 12-Feb-10 Banner Budget Auth 12-Feb-10
14729068 12-Feb-10 Purchasing Approvals 15-Feb-10
14729068 12-Feb-10 Department Approvals 15-Feb-10
14729068 12-Feb-10 Grant Approvals 15-Feb-10


[/data]


this is the new code.

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Dim rst As DAO.Recordset
  4. Dim rstTemp As Recordset
  5. Dim i As Long
  6. Dim dbs As DAO.Database
  7. Dim strSQL As String
  8.  
  9. Dim strFirstRec As String
  10.  
  11. '*********temp fields for writing records
  12. Dim strPR_ID_TEMP As String
  13. Dim strWorkflow_Step_Order_TEMP As Integer
  14. Dim strWorkflow_Step_Name_TEMP As String
  15. Dim strWorkflow_Step_Date_TEMP As Date
  16. Dim strPR_Date_TEMP As Date
  17. Dim strCountOfWorkflow_Step_Date_TEMP As Integer
  18.  
  19.  
  20. Private Sub Generate__PR_Status_Table_Click()
  21. On Error GoTo Err_Hndlr
  22.  
  23.  
  24. 'Delete temporary table
  25. DoCmd.RunSQL "DROP TABLE tblTemp;"
  26.  
  27. 'Create temporary table
  28. CurrentDb.Execute ("CREATE TABLE tblTemp(PR_Id integer, PR_Date DATETIME, Workflow_Step_Order smallint, Workflow_Step_Name VARCHAR(50), Workflow_Step_Date DATETIME, CountOfWorkflow_Step_Date smallint)")
  29.  
  30. 'Bind rstTemp to the temporary table
  31. Set rstTemp = CurrentDb.OpenRecordset("tblTemp")
  32.  
  33.  
  34. 'Grab the data and put it in rst
  35. Set rst = CurrentDb.OpenRecordset("SELECT T_PRApprovalHistory.PR_ID,  " & _
  36.                 "T_PRApprovalHistory.PR_Date,  " & _
  37.                 "tblWorkflowApprovalStep.Workflow_Step_Order, " & _
  38.                 "T_PRApprovalHistory.Workflow_Step_Name,  " & _
  39.                 "T_PRApprovalHistory.Workflow_Step_Date,  " & _
  40.                 "Count(T_PRApprovalHistory.Workflow_Step_Date) AS CountOfWorkflow_Step_Date " & _
  41.         "FROM T_PRApprovalHistory INNER JOIN tblWorkflowApprovalStep ON T_PRApprovalHistory.Workflow_Step_Name = tblWorkflowApprovalStep.Workflow_Step_Name " & _
  42.         "GROUP BY T_PRApprovalHistory.PR_ID, T_PRApprovalHistory.PR_Date, tblWorkflowApprovalStep.Workflow_Step_Order, T_PRApprovalHistory.Workflow_Step_Name, T_PRApprovalHistory.Workflow_Step_Date " & _
  43.         "HAVING (((T_PRApprovalHistory.PR_ID)=13728252)or " & _
  44.                     "((T_PRApprovalHistory.PR_ID)=14264637)or " & _
  45.                     "((T_PRApprovalHistory.PR_ID)=14265338)or " & _
  46.                     "((T_PRApprovalHistory.PR_ID)=11050390)or " & _
  47.                     "((T_PRApprovalHistory.PR_ID)=11050254)or " & _
  48.                     "((T_PRApprovalHistory.PR_ID)=14729068)) " & _
  49.         "ORDER BY T_PRApprovalHistory.PR_ID, tblWorkflowApprovalStep.Workflow_Step_Order, T_PRApprovalHistory.Workflow_Step_Date")
  50.  
  51.  
  52. 'Move the data into the temporary table
  53. rst.MoveFirst
  54. Do While rst.EOF = False
  55.     rstTemp.AddNew
  56.         For i = 0 To rst.Fields.Count - 1
  57.             rstTemp.Fields(i).Value = rst.Fields(i).Value
  58.         Next
  59.     rstTemp.Update
  60.     rst.MoveNext
  61. Loop
  62.  
  63. rst.Close
  64.  
  65. '********************************************************logic*****************************************
  66.  
  67. strFirstRec = "Yes"
  68.  
  69. ' **** initialize temporary fields, date is set to dummy initial date, it has no meaning
  70.  
  71. strPR_ID_TEMP = " "
  72. strPR_Date_TEMP = "03/19/2007"
  73. strWorkflow_Step_Order_TEMP = "0"
  74. strWorkflow_Step_Name_TEMP = " "
  75. strWorkflow_Step_Date_TEMP = "03/19/2007"
  76. strCountOfWorkflow_Step_Date_TEMP = "0"
  77.  
  78. '**** create output table
  79. 'Delete temporary table
  80. DoCmd.RunSQL "DROP TABLE tblApprovalHistorySummary;"
  81.  
  82. 'Create temporary table
  83. CurrentDb.Execute ("CREATE TABLE tblApprovalHistorySummary(PR_Id integer, PR_Date DATETIME, Workflow_Step_Order smallint, Workflow_Step_Name VARCHAR(50), Workflow_Step_Date DATETIME, CountOfWorkflow_Step_Date smallint)")
  84.  
  85. 'Bind rstTemp to the temporary table
  86. Set rstSummary = CurrentDb.OpenRecordset("tblApprovalHistorySummary")
  87.  
  88.  
  89. rstTemp.MoveFirst
  90.  
  91. Do While rstTemp.EOF = False
  92.  
  93.     Debug.Print "Temp file "; rstTemp!PR_ID&; " "; rstTemp!PR_Date&; " "; rstTemp!Workflow_Step_Name&; " "; rstTemp!workflow_Step_Date
  94.  
  95.     If strFirstRec = "Yes" Then
  96.         strFirstRec = "No"
  97.         strPR_ID_TEMP = rstTemp!PR_ID
  98.         strPR_Date_TEMP = rstTemp!PR_Date
  99.         strWorkflow_Step_Order_TEMP = rstTemp!Workflow_Step_Order
  100.         strWorkflow_Step_Date_TEMP = rstTemp!workflow_Step_Date
  101.         strWorkflow_Step_Name_TEMP = rstTemp!Workflow_Step_Name
  102.         strCountOfWorkflow_Step_Date_TEMP = rstTemp!CountOfWorkflow_Step_Date
  103.     End If
  104.  
  105.     If rstTemp!PR_ID = strPR_ID_TEMP Then
  106.         If rstTemp!Workflow_Step_Name = strWorkflow_Step_Name_TEMP Then
  107.             If rstTemp!workflow_Step_Date = strWorkflow_Step_Date_TEMP Then
  108.                 strWorkflow_Step_Date_TEMP = rstTemp!workflow_Step_Date
  109.             End If
  110.         Else
  111. '***        write record
  112.             rstSummary.AddNew
  113.                 rstSummary!PR_ID = strPR_ID_TEMP
  114.                 rstSummary!PR_Date = strPR_Date_TEMP
  115.                 rstSummary!Workflow_Step_Order = strWorkflow_Step_Order_TEMP
  116.                 rstSummary!Workflow_Step_Name = strWorkflow_Step_Name_TEMP
  117.                 rstSummary!workflow_Step_Date = strWorkflow_Step_Date_TEMP
  118.                 rstSummary!CountOfWorkflow_Step_Date = strCountOfWorkflow_Step_Date_TEMP
  119.             rstSummary.Update
  120.  
  121. '***  assign temp values
  122.                 strPR_ID_TEMP = rstTemp!PR_ID
  123.                 strPR_Date_TEMP = rstTemp!PR_Date
  124.                 strWorkflow_Step_Order_TEMP = rstTemp!Workflow_Step_Order
  125.                 strWorkflow_Step_Date_TEMP = rstTemp!workflow_Step_Date
  126.                 strWorkflow_Step_Name_TEMP = rstTemp!Workflow_Step_Name
  127.                 strCountOfWorkflow_Step_Date_TEMP = rstTemp!CountOfWorkflow_Step_Date
  128.         End If
  129.     Else
  130. '***   write record
  131.         rstSummary.AddNew
  132.             rstSummary!PR_ID = strPR_ID_TEMP
  133.             rstSummary!PR_Date = strPR_Date_TEMP
  134.             rstSummary!Workflow_Step_Order = strWorkflow_Step_Order_TEMP
  135.             rstSummary!Workflow_Step_Name = strWorkflow_Step_Name_TEMP
  136.             rstSummary!workflow_Step_Date = strWorkflow_Step_Date_TEMP
  137.             rstSummary!CountOfWorkflow_Step_Date = strCountOfWorkflow_Step_Date_TEMP
  138.         rstSummary.Update
  139.  
  140. '***  assign temp values
  141.         strPR_ID_TEMP = rstTemp!PR_ID
  142.         strPR_Date_TEMP = rstTemp!PR_Date
  143.         strWorkflow_Step_Order_TEMP = rstTemp!Workflow_Step_Order
  144.         strWorkflow_Step_Date_TEMP = rstTemp!workflow_Step_Date
  145.         strWorkflow_Step_Name_TEMP = rstTemp!Workflow_Step_Name
  146.         strCountOfWorkflow_Step_Date_TEMP = rstTemp!CountOfWorkflow_Step_Date
  147.     End If
  148.  
  149.     rstTemp.MoveNext
  150. Loop
  151.  
  152. rstTemp.Close
  153. rstSummary.Close
  154. Exit Sub
  155.  
  156.  
  157. Err_Hndlr:
  158.     MsgBox "[" & Err.Number & "]:  " & Err.Description, vbInformation, "Generate__PR_Status_Table_Click()"
  159. End Sub
Mar 10 '10 #25
patjones
931 Expert 512MB
Great! I'm glad it's working for now. When I get a chance I'll look at your data and see if there isn't a simpler way to accomplish what you want.

Pat
Mar 10 '10 #26

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Jim S. | last post by:
I'm having a horrible time simply inserting the date in a MySQL database through a Visual Basic program. I have a table, called "ORDERS"; "ID" is the primary key. I'm trying the insert the date,...
1
by: AS400 Guru | last post by:
I have this stored procedure that loops through a table and updates a couple of fields. For some reason one of the fields is not being updated. If I run the same code from query analyzer, it...
1
by: Don Leverton | last post by:
Hi Folks, I have been given a CD with approx 130 .xls files (bean-counters!) that I would like to import and merge to ONE table (tblTradeshow). The XL files are *similarly*, but not...
2
by: Robert McEuen | last post by:
Using Access 97, Windows XP I'm receiving a Numeric Field Overflow error during text import that I did not receive before I split my database. Another thread I found suggested that the cause of...
4
by: Josh | last post by:
Hi, I am trying to write a function in a module in MS Access 2000 that will change the data type of a field called 'Start' in table 'bo_cpm_CS01ALL'. Here is the code that I have done so far...
20
by: Prakash | last post by:
Hi ! I have a field "sub_tran_no" in my form in continuous view. When the user presses a button "Re-Number", I'd like to: 1) Save the current record pointer position 2) Save the current...
4
by: fmatamoros | last post by:
I sometimes get the following error from an update statement in a stored procedure: Transaction (Process ID 62) was deadlocked on thread | communication buffer resources with another process and...
1
by: cancer2006 | last post by:
I have to correct the ID field in 19 tables and there are 265 records affected in just one table . The id field is populated on the values from EInfo.ID, and EInfo.ID is based on the values from...
1
by: john | last post by:
LINQ works a lot like an Access DB Recordset in the way it functions, one of the things I could do in Access is refer to the Fields thru a Variable as below allowing me to Iterate over the...
0
by: Mike | last post by:
So here's the situation (.NET 2.0 btw): I have a form, and on this form is a textbox among many other databound controls. The textbox is bound to a field in a data table via the Text property. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.