I'm trying to update a table with some information from code and I'm having a bit of a problem with it. First, I'll show you my code and then explain my problem:
Private Sub btnApprv3_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![ManagerAppr]
If IsNull(DeptAppr) Then
[txtManagerAppr] = currentuser
[txtManagerApprDate] = Date
Me.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
End Sub
The problem that I'm having is that the fields actually get updated, but the table doesn't get updated until I close the form or move to another record on the form. I need to issue a command to input the data into the table. me.requery doesn't seem to have the desired affect.
Thanks,
Chris
Private Sub btnApprv3_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![ManagerAppr]
If IsNull(DeptAppr) Then
[txtManagerAppr] = currentuser
[txtManagerApprDate] = Date
Me.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
End Sub
The problem that I'm having is that the fields actually get updated, but the table doesn't get updated until I close the form or move to another record on the form. I need to issue a command to input the data into the table. me.requery doesn't seem to have the desired affect.
Thanks,
Chris