The form has two buttons. They are "Close" and "Save". If the form has had information added, but should not be saved, I want the user to be able to click on close and the form go away without adding a record. (Currently it adds the record.) Here is the code and you can see the attempts that I have made.
Do y'all have any suggestions?
Bubba
Do y'all have any suggestions?
Bubba
Code:
Private Sub Form_Load()
DoCmd.GoToRecord , , acNewRec
Provider_number.SetFocus
End Sub
Private Sub Save_Click()
On Error GoTo Err_Save_Click
Dim vPTestOK As Integer
Dim vSave As Boolean
vPTestOK = 1
vSave = True
If IsNull(Provider_number) Then
vPTestOK = MsgBox("Missing Provider Number! Save?", vbOKCancel, "PAC Track")
If vPTestOK = 1 Then
vSave = True 'Save regardless
Else
vSave = False 'Do not save record
End If
End If
If vSave = True Then
Me!Time = Time
DoCmd.GoToRecord , , acNewRec
GoTo Exit_Save_Click
Else
GoTo Exit_Save_Click
End If
Exit_Save_Click:
Provider_number.SetFocus
Exit Sub
Err_Save_Click:
MsgBox Err.Description
Resume Exit_Save_Click
End Sub
Private Sub Close_Click()
On Error GoTo Err_Close_Click
DoCmd.Close , , acSaveNo
'DoCmd.Quit (acQuitSaveNone)
'DoCmd.Quit acQuitSaveNone
Exit_Close_Click:
Exit Sub
Err_Close_Click:
MsgBox Err.Description
Resume Exit_Close_Click
End Sub