C
Chris A.
I'm using the following code to update 2 fields in a table
with the current users information and the date:
Private Sub btnApprv1_Click()
Dim db As Database
Dim rs As Recordset
Dim currentuser As String
Dim strSQL As String
Set db = CurrentDb()
currentuser = Forms!frmLogin!txtUserName
Date = Now()
ID = Forms!PurchaseRequisition!PRID
strSQL = strSQL & "SELECT * FROM tblPR WHERE "
strSQL = strSQL & "PRID = " & Forms!
PurchaseRequisition!PRID
Set rs = db.OpenRecordset(strSQL)
DeptAppr = rs![DeptAppr]
If IsNull(DeptAppr) Then
rs.FindFirst "[PRID] = " & ID
rs.Edit
rs![DeptAppr] = currentuser
rs![DeptApprDate] = Date
rs.Update
rs.Requery
MsgBox "Credentials Verified! PR approved!"
Else
MsgBox "This approval has already been marked
approved!"
End If
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
Me.Requery
End Sub
Everything in this code seems to be working great, but
when it gets to the line for Me.Requery to refresh the
information on the form, it gives me a write conflict and
says that another user has made changes to the code. The
message says that "the record has been changed by another
user since you started editing it." It then asks if I'd
like to "Save Record" which seems to undo the changes that
I just made, "Copy to Clipboard" which is useless,
or "Drop Changes" which seems to have the desired affect.
The issue is that I want to be able to excecute the above
code without having this box come up.
Does anyone have any suggestions?
Thanks,
Chris
with the current users information and the date:
Private Sub btnApprv1_Click()
Dim db As Database
Dim rs As Recordset
Dim currentuser As String
Dim strSQL As String
Set db = CurrentDb()
currentuser = Forms!frmLogin!txtUserName
Date = Now()
ID = Forms!PurchaseRequisition!PRID
strSQL = strSQL & "SELECT * FROM tblPR WHERE "
strSQL = strSQL & "PRID = " & Forms!
PurchaseRequisition!PRID
Set rs = db.OpenRecordset(strSQL)
DeptAppr = rs![DeptAppr]
If IsNull(DeptAppr) Then
rs.FindFirst "[PRID] = " & ID
rs.Edit
rs![DeptAppr] = currentuser
rs![DeptApprDate] = Date
rs.Update
rs.Requery
MsgBox "Credentials Verified! PR approved!"
Else
MsgBox "This approval has already been marked
approved!"
End If
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
Me.Requery
End Sub
Everything in this code seems to be working great, but
when it gets to the line for Me.Requery to refresh the
information on the form, it gives me a write conflict and
says that another user has made changes to the code. The
message says that "the record has been changed by another
user since you started editing it." It then asks if I'd
like to "Save Record" which seems to undo the changes that
I just made, "Copy to Clipboard" which is useless,
or "Drop Changes" which seems to have the desired affect.
The issue is that I want to be able to excecute the above
code without having this box come up.
Does anyone have any suggestions?
Thanks,
Chris