Good evening, I have an unlinked form for entering data into a table. Yes, I know I can link it, but I would prefer to have the form filled out and verified before the data is written in the table. I have a save button with coding behind it to transfer the data from the form to the table using .update.
My issue today is that on this form, I have a field that has to be filled in or the coding will prevent the user from saving the record to the table. This field is at the top of the form, so to help the user from wasting time, I want to add a msgbox and coding to allow the user to exit the form if they do not have that information. Here is sample coding:
Dim cdomerr As Integer
If [LLEF_DOM].Value = "" Then
cdomerr = MsgBox("You have not entered a Date of Manufacture. Do you wish to quit?", vbYesNoCancel, "DOM Error")
If cdomerr = vbYes Then 'They wish to exit
'close form
DoCmd.Close , , acSaveNo
Else
'return to field
[LLEF_TIME].SetFocus
[LLEF_DOM].SetFocus
End If
I get an error that the Docmd cannot be performed from a "on lost focus" event procedure. I understand why. I tried putting the code on the "after Update" event procedure, but if the operator just tabs through the field, it doesn't work.
How can I program the form so that if the user merely tabs through the field (leaves it blank) a message box pops up and asks the user if they wish to quit. If answer is yes, the form closes.
Any help would be greatly appreciated