T
tracktraining
Hi All,
I have the following code to check if the doc+revision entered is in the doc
table. If it is not in the doc table, then a message appears and the user
needs to enter a new doc or revision; no data (entry) should go to the
empdocstatus until the information is correct. In my case, when I finish
entering the doc+revision (incorrectly) then click close, the message
appears, but the user is unable to enter the correct information and the
whole form is closed and the information is written to the empdocstatus
table.
How can I fix this? Please help if possible.
'Check If Document+Revision Exist
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim db As Database
Dim rst As DAO.Recordset
Dim strSQL As String
Dim DataErr As String
Dim Response As String
newDocID = Me.DocID
newRevision = Me.Revision
chkdocstatus = True
strSQL = " SELECT * FROM DocInfo WHERE DocInfo.DocID = '" + newDocID +
"' AND " & _
" DocInfo.Revision = '" + newRevision + "'"
Set db = CurrentDb
Set rst = db.OpenRecordset(strSQL)
If rst.EOF Then
chkdocstatus = False
MsgBox "Document Number/Revision Wrong form_beforeupdate."
Me.Revision.SetFocus
Me.DocID.SetFocus
End If
End Sub
Thanks,
Tracktraining
I have the following code to check if the doc+revision entered is in the doc
table. If it is not in the doc table, then a message appears and the user
needs to enter a new doc or revision; no data (entry) should go to the
empdocstatus until the information is correct. In my case, when I finish
entering the doc+revision (incorrectly) then click close, the message
appears, but the user is unable to enter the correct information and the
whole form is closed and the information is written to the empdocstatus
table.
How can I fix this? Please help if possible.
'Check If Document+Revision Exist
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim db As Database
Dim rst As DAO.Recordset
Dim strSQL As String
Dim DataErr As String
Dim Response As String
newDocID = Me.DocID
newRevision = Me.Revision
chkdocstatus = True
strSQL = " SELECT * FROM DocInfo WHERE DocInfo.DocID = '" + newDocID +
"' AND " & _
" DocInfo.Revision = '" + newRevision + "'"
Set db = CurrentDb
Set rst = db.OpenRecordset(strSQL)
If rst.EOF Then
chkdocstatus = False
MsgBox "Document Number/Revision Wrong form_beforeupdate."
Me.Revision.SetFocus
Me.DocID.SetFocus
End If
End Sub
Thanks,
Tracktraining