To anyone -
I have a form where scrap is entered into a listview control on that form. I have made it so if the user dbl clicks the control he/she can edit the information. I can update the information no problem. My problem comes when I go to close the form I get a message saying Write Conflict and someone else may be editing it. I'm the only one on there so that's not the problem. My code is a bit patchy as I've been trying to move stuff around to avoid this so please be gentle with me.
strcompname = Environ("COMPUTERNAME") & "scrap"
strSQL = "UPDATE " & strcompname & " SET[Date Entered]=#" & dtmdate & "#,"
strSQL = strSQL & "[Time Entered]=#" & dtmtime & "#,[Name]=""" & strname & ""","
strSQL = strSQL & "[Shift]='" & strshift & "',[Area]='" & strarea & "',"
strSQL = strSQL & "[Part Number]='" & strpartnumber & "',[WO Number]='" & strwonumber & "',"
strSQL = strSQL & "[Category]='" & strdefectgroup & "',[Reason]='" & strdefectreason & "',"
strSQL = strSQL & "[Qty]=" & lngqty & ""
strSQL = strSQL & " WHERE([Incr]=" & intincr & ");"
DoCmd.SetWarnings False
DoCmd.RunSQL (strSQL)
DoCmd.SetWarnings True
strSQL = "SELECT * FROM " & strcompname & ";"
On Error GoTo ErrorHandler
Set db = CurrentDb()
Set rs = db.OpenRecordset(strSQL)
With Form_frmproduction.lviewscrap
'Set ListView style
.View = lvwReport
'This is not supported by ListView 5
.GridLines = False
.FullRowSelect = True
.GridLines = False
.FullRowSelect = True
.AllowColumnReorder = True
'Clear Header and ListItems
.ListItems.Clear
End With
' Add items and subitems to list control.
rs.MoveFirst
Do Until rs.EOF
Set lstItem = Form_frmproduction.lviewscrap.ListItems.Add()
lstItem.Text = Nz(rs!Incr)
lstItem.SubItems(1) = Nz(rs![Date entered])
lstItem.SubItems(2) = Nz(rs![Time Entered])
lstItem.SubItems(3) = Nz(rs![Name])
lstItem.SubItems(4) = Nz(rs![Shift])
lstItem.SubItems(5) = Nz(rs![Area])
lstItem.SubItems(6) = Nz(rs![Part Number])
lstItem.SubItems(7) = Nz(rs![WO Number])
lstItem.SubItems(8) = Nz(rs![Category])
lstItem.SubItems(9) = Nz(rs![Reason])
lstItem.SubItems(10) = Nz(rs![Qty])
lstItem.SubItems(11) = Nz(rs![Comments])
'Next row
rs.MoveNext
Loop
'close recordset
rs.Close
Set rs = Nothing
DoCmd.Echo True
ErrorHandlerExit:
Exit Sub
ErrorHandler:
If Err = 3021 Then ' no current record
Resume Next
Else
MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
Resume ErrorHandlerExit
End If
DoCmd.Close acForm, "frmscrapchange" 'This is where I'm getting the Write Conflicts
Any help would be WONDERFUL!!!
Thanks
I have a form where scrap is entered into a listview control on that form. I have made it so if the user dbl clicks the control he/she can edit the information. I can update the information no problem. My problem comes when I go to close the form I get a message saying Write Conflict and someone else may be editing it. I'm the only one on there so that's not the problem. My code is a bit patchy as I've been trying to move stuff around to avoid this so please be gentle with me.
strcompname = Environ("COMPUTERNAME") & "scrap"
strSQL = "UPDATE " & strcompname & " SET[Date Entered]=#" & dtmdate & "#,"
strSQL = strSQL & "[Time Entered]=#" & dtmtime & "#,[Name]=""" & strname & ""","
strSQL = strSQL & "[Shift]='" & strshift & "',[Area]='" & strarea & "',"
strSQL = strSQL & "[Part Number]='" & strpartnumber & "',[WO Number]='" & strwonumber & "',"
strSQL = strSQL & "[Category]='" & strdefectgroup & "',[Reason]='" & strdefectreason & "',"
strSQL = strSQL & "[Qty]=" & lngqty & ""
strSQL = strSQL & " WHERE([Incr]=" & intincr & ");"
DoCmd.SetWarnings False
DoCmd.RunSQL (strSQL)
DoCmd.SetWarnings True
strSQL = "SELECT * FROM " & strcompname & ";"
On Error GoTo ErrorHandler
Set db = CurrentDb()
Set rs = db.OpenRecordset(strSQL)
With Form_frmproduction.lviewscrap
'Set ListView style
.View = lvwReport
'This is not supported by ListView 5
.GridLines = False
.FullRowSelect = True
.GridLines = False
.FullRowSelect = True
.AllowColumnReorder = True
'Clear Header and ListItems
.ListItems.Clear
End With
' Add items and subitems to list control.
rs.MoveFirst
Do Until rs.EOF
Set lstItem = Form_frmproduction.lviewscrap.ListItems.Add()
lstItem.Text = Nz(rs!Incr)
lstItem.SubItems(1) = Nz(rs![Date entered])
lstItem.SubItems(2) = Nz(rs![Time Entered])
lstItem.SubItems(3) = Nz(rs![Name])
lstItem.SubItems(4) = Nz(rs![Shift])
lstItem.SubItems(5) = Nz(rs![Area])
lstItem.SubItems(6) = Nz(rs![Part Number])
lstItem.SubItems(7) = Nz(rs![WO Number])
lstItem.SubItems(8) = Nz(rs![Category])
lstItem.SubItems(9) = Nz(rs![Reason])
lstItem.SubItems(10) = Nz(rs![Qty])
lstItem.SubItems(11) = Nz(rs![Comments])
'Next row
rs.MoveNext
Loop
'close recordset
rs.Close
Set rs = Nothing
DoCmd.Echo True
ErrorHandlerExit:
Exit Sub
ErrorHandler:
If Err = 3021 Then ' no current record
Resume Next
Else
MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
Resume ErrorHandlerExit
End If
DoCmd.Close acForm, "frmscrapchange" 'This is where I'm getting the Write Conflicts
Any help would be WONDERFUL!!!
Thanks