Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select and If together. 1

Status
Not open for further replies.

lars7

Technical User
Aug 16, 2005
817
GB
Hi,
I am trying to get the following code to close the form without saveing if the message box answer is "No" but I don't want it to save if "text1" is null. At the moment the form wont close if "text1" is null. So if the form is opened just to view it wont close.

Private Sub Command6_Click()
On Error GoTo Err_Command6_Click
Dim intReturn As Integer
intReturn = MsgBox("Would you like to save this record?", vbYesNo + vbDefaultButton3, "Save changes?")
Select Case intReturn
Case vbYes
'Do Nothing
Case vbNo
Me.Undo
End Select
If IsNull(Me!text1) Then
Beep
MsgBox "Additional pay number cannot be null", vbExclamation, "Required selection"
Else
DoCmd.Close
End If
Exit_Command6_Click:
Exit Sub
Err_Command6_Click:
MsgBox Err.Description
Resume Exit_Command6_Click
End Sub
 
Perhaps this ?
If IsNull(Me!text1) And Me.Dirty Then

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks PHV,
That worked. Now I will try to find out wny.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top