T
Tony Williams
I have a form that has 2 controls that the user must complete before the
record is saved. Here is my code:
If IsNull(DocNametxt.Value) Then
MsgBox "You cannot save a record without a Document Name. Please
enter a name.", vbCritical, "Name Required"
[DocNametxt].SetFocus
If IsNull(cmbAuthor.Value) Then
MsgBox "You cannot save a record without an Author." & vbCrLf &
"Please enter an Author's name.", vbCritical, "Name Required"
[cmbAuthor].SetFocus
Else
Answer = MsgBox("Are you sure you want to save this record?", 36, "Enter New
Record")
If Answer = vbYes Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70
End If
End If
End If
DoCmd.Close
The problem is if the DocNametxt or cmbAuthor are blank both messages
appear and the "Are you sure you want to save this record?" message appear
and then the form closes. It doesn't give the user the oppurtunity to
complete the blank controls and then carry on.
What am I doing wrong? This code is behind a command button that is cmdSave
TIA
Tony Williams
record is saved. Here is my code:
If IsNull(DocNametxt.Value) Then
MsgBox "You cannot save a record without a Document Name. Please
enter a name.", vbCritical, "Name Required"
[DocNametxt].SetFocus
If IsNull(cmbAuthor.Value) Then
MsgBox "You cannot save a record without an Author." & vbCrLf &
"Please enter an Author's name.", vbCritical, "Name Required"
[cmbAuthor].SetFocus
Else
Answer = MsgBox("Are you sure you want to save this record?", 36, "Enter New
Record")
If Answer = vbYes Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70
End If
End If
End If
DoCmd.Close
The problem is if the DocNametxt or cmbAuthor are blank both messages
appear and the "Are you sure you want to save this record?" message appear
and then the form closes. It doesn't give the user the oppurtunity to
complete the blank controls and then carry on.
What am I doing wrong? This code is behind a command button that is cmdSave
TIA
Tony Williams