Guest_imported
New member
- Jan 1, 1970
- 0
I'm trying to code my form so that if the Filenumber is empty it will not store the information in its accompanying table. I tried the code in the Filenumber property settings under Before_Update, After_Update, On_Change and (The filenumber field is a text box) it worked with only one BIG problem. It still stored the information in the table. This is what I did, I typed in Data into the textfield "Filenumber" and then I went to the next textbox. After that I closed the form completely. I have the "Add New Record" button on my form so this is what I expect the user to have to push if they want the record to be saved. If the user just exits out of form it should not save the record. I don't want access to save the information unless the "Add New" icon is pushed. I received the code below from someone but it doesn't work. When I test it out, it keeps on outputting the Msgbox when I try to click the Filenumber textbox that is on the main form. I also tried to put the code in the "Add New" On_click property but it still stored the information.
Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Forms!General!Filenumber) Then
MsgBox "Must contain info"
Forms!General!Filenumber.SetFocus
DoCmd.CancelEvent
Exit Sub
End If
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Forms!General!Filenumber) Then
MsgBox "Must contain info"
Forms!General!Filenumber.SetFocus
DoCmd.CancelEvent
Exit Sub
End If
End Sub