T
tracktraining
Hi ALL,
There are three messages appearing at different condition that i want to
have in my save button. I have the following code and I am having problems
with the if, elseif, else statement (or maybe i am not supposed to use the
if, elseif statement?)
Private Sub btnsave_Click()
On Error GoTo Err_btnsave_Click
Dim db As Database
Dim rst As DAO.Recordset
Dim rs As DAO.Recordset
Dim strSQL As String
Dim strSQLD As String
Dim Response As String
newDocID = Me.DocID
newRevision = Me.Revision
strSQL = " SELECT * FROM DocInfo WHERE DocInfo.DocID = '" + newDocID +
"' AND " & _
" DocInfo.Revision = '" + newRevision + "'"
strSQLD = "SELECT * FROM EmpDocStatus WHERE EmpDocStatus.EmpEmail =
Me.EmpEmail AND " & _
" EmpDocStatus.DocID = Me.DocID AND EmpDocStatus.Revision =
Me.Revision"
Set db = CurrentDb
Set rst = db.OpenRecordset(strSQL)
Set rs = db.OpenRecordset(strSQLD)
If rst.EOF Then
MsgBox "Document Number/Revision Wrong button save click."
Me.DocID.SetFocus
Else If rs.EOF
MsgBox "Document Number + Revision Has Already Been Assigned To
Employee."
Me.DocID.SetFocus
Else
MsgBox "Training Record Is Updated."
Me.FilterOn = False
'DoCmd.Close
End If
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Exit_btnsave_Click:
Exit Sub
Err_btnsave_Click:
MsgBox Err.Description
Resume Exit_btnsave_Click
End Sub
Please let me know if there is a better way of writing this.
Thanks,
Tracktraining
There are three messages appearing at different condition that i want to
have in my save button. I have the following code and I am having problems
with the if, elseif, else statement (or maybe i am not supposed to use the
if, elseif statement?)
Private Sub btnsave_Click()
On Error GoTo Err_btnsave_Click
Dim db As Database
Dim rst As DAO.Recordset
Dim rs As DAO.Recordset
Dim strSQL As String
Dim strSQLD As String
Dim Response As String
newDocID = Me.DocID
newRevision = Me.Revision
strSQL = " SELECT * FROM DocInfo WHERE DocInfo.DocID = '" + newDocID +
"' AND " & _
" DocInfo.Revision = '" + newRevision + "'"
strSQLD = "SELECT * FROM EmpDocStatus WHERE EmpDocStatus.EmpEmail =
Me.EmpEmail AND " & _
" EmpDocStatus.DocID = Me.DocID AND EmpDocStatus.Revision =
Me.Revision"
Set db = CurrentDb
Set rst = db.OpenRecordset(strSQL)
Set rs = db.OpenRecordset(strSQLD)
If rst.EOF Then
MsgBox "Document Number/Revision Wrong button save click."
Me.DocID.SetFocus
Else If rs.EOF
MsgBox "Document Number + Revision Has Already Been Assigned To
Employee."
Me.DocID.SetFocus
Else
MsgBox "Training Record Is Updated."
Me.FilterOn = False
'DoCmd.Close
End If
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Exit_btnsave_Click:
Exit Sub
Err_btnsave_Click:
MsgBox Err.Description
Resume Exit_btnsave_Click
End Sub
Please let me know if there is a better way of writing this.
Thanks,
Tracktraining