For the purposes of my database, I need to have a Last Name Field, First Name field and a File As field, however, in many cases, the File As field will be "last name, first name". So, I want to set up the form so that when the File As field gets the focus (either OnFocus or OnEnter), if it is empty, it is automatically filled with LastName, FirstName. I have attempted this with the following code:
Private Sub FileName_Enter()
If IsNull Then
Me.FileName = Me.LastName + ", " + Me.FirstName
Else: Me.FileName.SetFocus
End Sub
When I enter the FileAs Field, whether it is empty or not, as soon as I tab/Click it I get an error message: Compile Error, Argument Not Optional and IsNull is highlighted. If I take out the If statement and just leave me.Filename = ...... then it works. The trouble is, if something has already been entered into the FileAs field, I don't want it changed.