First of all i hope this is in the right discussion and sorry for the long post
Hopefully someone can point me in the right direction as i cant figure this out.
I have a form used to add new customers which works fine for adding customers but if i get to the end and then want to cancel it the form still adds it.
Heres the code i have so far:
Select Case Me.Select1
Case "y"
DoCmd.GoToRecord , , acNewRec
MsgBox "New record added", vbOKOnly
Me.Select1 = Null
Me.AccountCode.SetFocus
Case "n"
MsgBox "Are you sure you want to delete this record", vbYesNo
If vbYes Then
DoCmd.RunCommand acCmdDeleteRecord
MsgBox "Record Deleted", vbOKOnly
Me.AccountCode.SetFocus
End If
If vbNo Then
Me.Select1 = Null
Me.Select1.SetFocus
End If
Case Else
MsgBox "Please enter 'Y' or 'N' only", vbOKOnly
Me.Select1.SetFocus
End Select
Basically what is supposed to happen is i enter all the details into the text boxes on the form and i get to the last box which is an unbound textbox(select1) and i either enter y to add the customer details to the table and a message box pops up to say the record is added (got this working).
If i get to select1 and enter n then i want a message box to pop up asking if im sure i want to delete this record with the yes and no buttons, if i select yes on the message box then the record is deleted but if i select no then i want the record to still be there and the focus set on select1 so i can select any of the other text boxes to change the details and i also want another textbox to pop up if anything else is entered into select one or there is nothing entered atall to say "please enter y or n only"
Hope this sort of makes sense
Thanks
Gareth
Hopefully someone can point me in the right direction as i cant figure this out.
I have a form used to add new customers which works fine for adding customers but if i get to the end and then want to cancel it the form still adds it.
Heres the code i have so far:
Select Case Me.Select1
Case "y"
DoCmd.GoToRecord , , acNewRec
MsgBox "New record added", vbOKOnly
Me.Select1 = Null
Me.AccountCode.SetFocus
Case "n"
MsgBox "Are you sure you want to delete this record", vbYesNo
If vbYes Then
DoCmd.RunCommand acCmdDeleteRecord
MsgBox "Record Deleted", vbOKOnly
Me.AccountCode.SetFocus
End If
If vbNo Then
Me.Select1 = Null
Me.Select1.SetFocus
End If
Case Else
MsgBox "Please enter 'Y' or 'N' only", vbOKOnly
Me.Select1.SetFocus
End Select
Basically what is supposed to happen is i enter all the details into the text boxes on the form and i get to the last box which is an unbound textbox(select1) and i either enter y to add the customer details to the table and a message box pops up to say the record is added (got this working).
If i get to select1 and enter n then i want a message box to pop up asking if im sure i want to delete this record with the yes and no buttons, if i select yes on the message box then the record is deleted but if i select no then i want the record to still be there and the focus set on select1 so i can select any of the other text boxes to change the details and i also want another textbox to pop up if anything else is entered into select one or there is nothing entered atall to say "please enter y or n only"
Hope this sort of makes sense
Thanks
Gareth