ms access hangs up during rs.update??

aksesvibiey

New member
Local time
Today, 00:17
Joined
Feb 26, 2007
Messages
7
hello..

I have this problem that when I update the value in one of my tables, MS Access hangs up. I don't know why. I dont know if it's because of the updating or because of something else.. Any help would be greatly appreciated.. Thanks in advance! ;)

here the code that's executed when the approve button is clicked..

Private Sub Command43_Click()

Answer = MsgBox("Are you sure you want to approve this timesheet? Note that only projects approved by respective project managers will be approved.", vbYesNo)
'if cancelled
If Answer = vbNo Then
Else
Dim rs As Object
Dim x As Integer 'will be used as a flag for do while loop

x = 1 'initialize flag
Set rs = Me.Recordset.Clone

rs.FindFirst "[weekending] = #" & Format(Me![weekending], "mm\/dd\/yyyy") & "#"

'finding the first record wich matches the weekending doesn't give the right record
'right away. it may give a record with the right weekending but different eno. that is
'not supposed to happen. so once a weekending match is found, check if the eno also
'matches. this do..while loop will do the trick =)
Do While x < 18
If rs!eno = Forms!TimesheetDetailsFrm!eno And rs!statusPM = "approved" Then
rs.Edit
rs!status = "approved"
rs.Update
x = x + 1
End If
rs.FindNext "[weekending] = #" & Format(Me![weekending], "mm\/dd\/yyyy") & "#"
Loop

'close this form and refresh the 'timesheets for approval' form
Answer = MsgBox("You have successfully approved the timesheet. Close this window to continue viewing other submitted timesheets.")
Forms!SupervisorFrm.Requery
End If

End Sub


Thanks again..

ps. How do I mark a post as 'resolved'? Coz I have a previous post which has already been solved.. Thanks to all of you guys. ;)
 
I'm guessing that x is not being incremented because it falls within an if statement (that is not returning true 18 times)

Try moving x = x + 1 so that it is immediately above Loop (or certainly after End If)

Code:
Do While x < 18
  If rs!eno = Forms!TimesheetDetailsFrm!eno And rs!statusPM = "approved" Then
    rs.Edit
    rs!status = "approved"
    rs.Update
  End If
  rs.FindNext "[weekending] = #" & Format(Me![weekending], "mm\/dd\/yyyy") & "#"
  x = x + 1
Loop
 

Users who are viewing this thread

Back
Top Bottom